aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2017-05-24 14:24:47 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2017-05-24 14:24:47 +0000
commit880f26f3eb4d5045dd8a44283022590efc074365 (patch)
treee3bca48bef38f6854227808be6566d5fe1ed716c /usr.sbin
parente058e1c43c8c5dfdc7d81d66a97a6992ae2c63db (diff)
downloadsrc-880f26f3eb4d5045dd8a44283022590efc074365.tar.gz
src-880f26f3eb4d5045dd8a44283022590efc074365.zip
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).
Notes
Notes: svn path=/head/; revision=318788
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/bhyvegc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/bhyve/bhyvegc.c b/usr.sbin/bhyve/bhyvegc.c
index 377b05b0878f..0987e39dbb6b 100644
--- a/usr.sbin/bhyve/bhyvegc.c
+++ b/usr.sbin/bhyve/bhyvegc.c
@@ -1,4 +1,5 @@
#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
#include <sys/types.h>
@@ -56,9 +57,11 @@ bhyvegc_resize(struct bhyvegc *gc, int width, int height)
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));
}
}