From owner-svn-src-head@freebsd.org Mon Dec 21 03:32: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 61187A4EC28; Mon, 21 Dec 2015 03:32:11 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-oi0-x236.google.com (mail-oi0-x236.google.com [IPv6:2607:f8b0:4003:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 288531205; Mon, 21 Dec 2015 03:32:11 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-oi0-x236.google.com with SMTP id l9so57239474oia.2; Sun, 20 Dec 2015 19:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=4TxSK8jCGMtonFFfghkzRwrHxYGxrqpL2DwvTZAmTS0=; b=fpoKN+hNV1BfJeg06sthaeEA0Vjvr8YevJgIqCVAX1Ja5u5BSlXEGeyInb52iMp8Gw AybmPP//bY8qi2zBGCZ9EwEAsni2benCDXHtm1ze3hZNmxgeQdoFfdDmHnGQoRltoZ+r QvI6Tqiio70TxSbz/FCu2RXPH8YNhgg9wOd81gEfZH9aGTarhCChFwdIlVAjHnh4xznR mAo5lLsrp19V0SLOrQm3oalHjXOUCzfOFf0PNpr1EcGx+RB/56MrfbdZv36BYQd9wa/u YWPEVjut4XyacUMknbeqEuqZB3M6EcReSOtcW8YtmsK5PNsyM1IAEWDlGeHH7lLc6/Zu iJKw== MIME-Version: 1.0 X-Received: by 10.202.173.9 with SMTP id w9mr6168696oie.79.1450668730359; Sun, 20 Dec 2015 19:32:10 -0800 (PST) Received: by 10.182.7.33 with HTTP; Sun, 20 Dec 2015 19:32:10 -0800 (PST) Reply-To: araujo@FreeBSD.org In-Reply-To: <3897533.TozUtTrSHk@ralph.baldwin.cx> References: <201512172042.tBHKg5bM091931@repo.freebsd.org> <30CD0290-06B9-4024-8EEE-F25090608D46@gmail.com> <3897533.TozUtTrSHk@ralph.baldwin.cx> Date: Mon, 21 Dec 2015 11:32:10 +0800 Message-ID: Subject: Re: svn commit: r292410 - head/usr.sbin/boot0cfg From: Marcelo Araujo To: John Baldwin Cc: Garrett Cooper , luke , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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: Mon, 21 Dec 2015 03:32:11 -0000 2015-12-19 1:50 GMT+08:00 John Baldwin : > 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. :-/ > > Understandable reason, but all the rest of the code is using that style, bde@ has mentioned about it too. In other hand, the change is too small to have another ci to fix it. Best, -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)