From owner-svn-src-head@freebsd.org Fri Dec 18 19:50:11 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3386A4A78C; Fri, 18 Dec 2015 19:50:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A27F11B52; Fri, 18 Dec 2015 19:50:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A1C25B95B; Fri, 18 Dec 2015 14:50:10 -0500 (EST) From: John Baldwin To: araujo@freebsd.org Cc: Garrett Cooper , luke , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Subject: Re: svn commit: r292410 - head/usr.sbin/boot0cfg Date: Fri, 18 Dec 2015 09:50:25 -0800 Message-ID: <3897533.TozUtTrSHk@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: <201512172042.tBHKg5bM091931@repo.freebsd.org> <30CD0290-06B9-4024-8EEE-F25090608D46@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 18 Dec 2015 14:50:10 -0500 (EST) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2015 19:50:11 -0000 On Friday, December 18, 2015 02:17:16 PM Marcelo Araujo wrote: > 2015-12-18 13:53 GMT+08:00 Garrett Cooper : > > > > > > On Dec 17, 2015, at 21:36, luke wrote: > > > > > >> On Fri, Dec 18, 2015 at 4:42 AM, John Baldwin wrote: > > >> Author: jhb > > >> Date: Thu Dec 17 20:42:05 2015 > > >> New Revision: 292410 > > >> URL: https://svnweb.freebsd.org/changeset/base/292410 > > >> > > >> Log: > > >> Exit cleanly if malloc() fails to allocate a buffer for a copy of the > > >> current MBR. > > >> > > >> PR: 205322 > > >> Submitted by: Alexander Kuleshov > > >> MFC after: 1 week > > >> > > >> Modified: > > >> head/usr.sbin/boot0cfg/boot0cfg.c > > >> > > >> Modified: head/usr.sbin/boot0cfg/boot0cfg.c > > >> > > ============================================================================== > > >> --- head/usr.sbin/boot0cfg/boot0cfg.c Thu Dec 17 20:33:20 2015 > > (r292409) > > >> +++ head/usr.sbin/boot0cfg/boot0cfg.c Thu Dec 17 20:42:05 2015 > > (r292410) > > >> @@ -337,6 +337,8 @@ read_mbr(const char *disk, u_int8_t **mb > > >> return (mbr_size); > > >> } > > >> *mbr = malloc(sizeof(buf)); > > >> + if (mbr == NULL) > > >> + errx(1, "%s: unable to allocate MBR buffer", disk); > > >> memcpy(*mbr, buf, sizeof(buf)); > > >> close(fd); > > > > > > > Hi, > > > > > > Should the check be against *mbr ? > > > + if (*mbr == NULL) > > > + errx(1, "%s: unable to allocate MBR buffer", disk); > > > > Yup! > > > > +1 > > Could be write as: > if ((*mbr = malloc(sizeof(buf))) == NULL) > errx(1, "%s: unable to allocate MBR buffer", disk); Yes, but I don't like side effects in conditionals. OTOH, changing away from that is how I fubar'd the original patch. :-/ -- John Baldwin