Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jan 2016 19:04:57 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r294338 - in stable: 10/usr.sbin/boot0cfg 9/usr.sbin/boot0cfg
Message-ID:  <201601191904.u0JJ4vDt099399@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Jan 19 19:04:56 2016
New Revision: 294338
URL: https://svnweb.freebsd.org/changeset/base/294338

Log:
  MFC 292410,292443,293977:
  Exit cleanly if malloc() fails to allocate a buffer for a copy of the
  current MBR.
  
  PR:		205322
  Submitted by:	Alexander Kuleshov <kuleshovmail@gmail.com>

Modified:
  stable/9/usr.sbin/boot0cfg/boot0cfg.c
Directory Properties:
  stable/9/usr.sbin/boot0cfg/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/usr.sbin/boot0cfg/boot0cfg.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/usr.sbin/boot0cfg/boot0cfg.c
==============================================================================
--- stable/9/usr.sbin/boot0cfg/boot0cfg.c	Tue Jan 19 18:57:37 2016	(r294337)
+++ stable/9/usr.sbin/boot0cfg/boot0cfg.c	Tue Jan 19 19:04:56 2016	(r294338)
@@ -334,7 +334,8 @@ read_mbr(const char *disk, u_int8_t **mb
 	    errx(1, "%s: short read", disk);
 	return (mbr_size);
     }
-    *mbr = malloc(sizeof(buf));
+    if ((*mbr = malloc(sizeof(buf))) == NULL)
+	errx(1, "%s: unable to allocate MBR buffer", disk);
     memcpy(*mbr, buf, sizeof(buf));
 
     return sizeof(buf);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601191904.u0JJ4vDt099399>