Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 May 2017 14:24:48 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r318788 - head/usr.sbin/bhyve
Message-ID:  <201705241424.v4OEOmIf053464@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Wed May 24 14:24:47 2017
New Revision: 318788
URL: https://svnweb.freebsd.org/changeset/base/318788

Log:
  bhyvegc_resize: make use of reallocarray(3) for bounds-checking.
  
  Also add __FBSDID.
  
  Reviewed by:	grehan
  
  This file lacks a license(!) so for this change the following declaration
  applies:
  
  To the greatest extent permitted by, but not in contravention of,
  applicable law, Affirmer hereby overtly, fully, permanently, irrevocably
  and unconditionally waives, abandons, and surrenders all of Affirmer's
  Copyright and Related Rights and associated claims and causes of action,
  whether now known or unknown (including existing as well as future claims
  and causes of action).

Modified:
  head/usr.sbin/bhyve/bhyvegc.c

Modified: head/usr.sbin/bhyve/bhyvegc.c
==============================================================================
--- head/usr.sbin/bhyve/bhyvegc.c	Wed May 24 14:22:22 2017	(r318787)
+++ head/usr.sbin/bhyve/bhyvegc.c	Wed May 24 14:24:47 2017	(r318788)
@@ -1,4 +1,5 @@
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 
@@ -56,9 +57,11 @@ bhyvegc_resize(struct bhyvegc *gc, int w
 	gc_image->width = width;
 	gc_image->height = height;
 	if (!gc->raw) {
-		gc_image->data = realloc(gc_image->data,
-		    sizeof (uint32_t) * width * height);
-		memset(gc_image->data, 0, width * height * sizeof (uint32_t));
+		gc_image->data = reallocarray(gc_image->data, width * height,
+		    sizeof (uint32_t));
+		if (gc_image->data != NULL)
+			memset(gc_image->data, 0, width * height *
+			    sizeof (uint32_t));
 	}
 }
 



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