svn commit: r294338 - in stable: 10/usr.sbin/boot0cfg 9/usr.sbin/boot0cfg

John Baldwin jhb at FreeBSD.org
Tue Jan 19 19:04:58 UTC 2016


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 at gmail.com>

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

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

Modified: stable/10/usr.sbin/boot0cfg/boot0cfg.c
==============================================================================
--- stable/10/usr.sbin/boot0cfg/boot0cfg.c	Tue Jan 19 18:57:37 2016	(r294337)
+++ stable/10/usr.sbin/boot0cfg/boot0cfg.c	Tue Jan 19 19:04:56 2016	(r294338)
@@ -336,7 +336,8 @@ read_mbr(const char *disk, u_int8_t **mb
 	close(fd);
 	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));
     close(fd);
 


More information about the svn-src-all mailing list