From owner-freebsd-current Wed Aug 7 16:41:56 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3FDA637B400; Wed, 7 Aug 2002 16:41:54 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E8DA43E42; Wed, 7 Aug 2002 16:41:53 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.5/8.12.5) with ESMTP id g77NfgmW001394; Thu, 8 Aug 2002 03:41:48 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.5/8.12.5/Submit) id g77Nfef0001393; Thu, 8 Aug 2002 03:41:41 +0400 (MSD) (envelope-from ache) Date: Thu, 8 Aug 2002 03:41:37 +0400 From: "Andrey A. Chernov" To: phk@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: phk malloc() sometimes forget to set errno Message-ID: <20020807234135.GA1359@nagual.pp.ru> References: <20020807232750.GA1168@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020807232750.GA1168@nagual.pp.ru> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Aug 08, 2002 at 03:27:52 +0400, Andrey A. Chernov wrote: > I found at least one case: > > -------------------------------------------- > imalloc(...) > ... > if ((size + malloc_pagesize) < size) /* Check for overflow */ > result = 0; > ... > return result; > -------------------------------------------- > > I.e. NULL returned, but errno is not set and can be even 0 > > Please fix this bug. According to POSIX, ENOMEM is required at least, but > EINVAL here is more applicable (as POSIX extension). Hmm. From second thought ENOMEM here will be right, since 'size' is valid. Other places without errno I found: all places with wrtwarning("...."); return 0; errno is not set here too. EINVAL or EFAULT... -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message