Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Dec 2015 20:42:05 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292410 - head/usr.sbin/boot0cfg
Message-ID:  <201512172042.tBHKg5bM091931@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <kuleshovmail@gmail.com>
  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);
 



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