From owner-svn-src-all@freebsd.org Fri Dec 18 06:17:17 2015 Return-Path: Delivered-To: svn-src-all@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 2ECDBA4A684; Fri, 18 Dec 2015 06:17:17 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-ob0-x241.google.com (mail-ob0-x241.google.com [IPv6:2607:f8b0:4003:c01::241]) (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 ED80C1982; Fri, 18 Dec 2015 06:17:16 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-ob0-x241.google.com with SMTP id ny9so6416157obb.0; Thu, 17 Dec 2015 22:17:16 -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=DV+3WG4T/hntYbiuwX+ye8wkYLRNgrSDtu5IydadX2E=; b=ifjX9WyJWs46sYwu/MULSzlFlEh0/XBTYMhR3rxrQNYSvWingMJjv3BecxAFW0Hkb/ LSE7n70VzHWEauIIvrbq2Uj/VZGKOsLUjWcuTcfWw1AF/MiEqA6TJ9KMSXwNOqJRmGGZ JvUAvtiiyBPscqjqQtvwO2BNzgUhmZcNDl+XL9f85PRIMjwHpDk6Z8UxVANmm7xPVHT6 0v80XkyuFUJ6j5FHDs0SqSZAXK1yntR4bv/ALr0Q2xmndljZSsp8VEQNbKRk7s2pmr+q OsUOWcfo0E1w6XYvJJ8fqYQY3IDoU+3VxGrRlW3l6aiA/o8lbdkaxzr32vIqDXz+Ee37 imlg== MIME-Version: 1.0 X-Received: by 10.60.39.200 with SMTP id r8mr799263oek.81.1450419436154; Thu, 17 Dec 2015 22:17:16 -0800 (PST) Received: by 10.182.7.33 with HTTP; Thu, 17 Dec 2015 22:17:16 -0800 (PST) Reply-To: araujo@FreeBSD.org In-Reply-To: <30CD0290-06B9-4024-8EEE-F25090608D46@gmail.com> References: <201512172042.tBHKg5bM091931@repo.freebsd.org> <30CD0290-06B9-4024-8EEE-F25090608D46@gmail.com> Date: Fri, 18 Dec 2015 14:17:16 +0800 Message-ID: Subject: Re: svn commit: r292410 - head/usr.sbin/boot0cfg From: Marcelo Araujo To: Garrett Cooper Cc: luke , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , John Baldwin Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2015 06:17:17 -0000 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); Br, -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)