[coreboot-gerrit] Patch set updated for coreboot: libpayload/libc: Fix memset/sizeof usage
Martin Roth (martinroth@google.com)
gerrit at coreboot.org
Tue Apr 5 17:10:21 CEST 2016
Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14244
-gerrit
commit b98262213f351dd83b55191da6add8a99b22de34
Author: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
Date: Mon Apr 4 19:52:35 2016 +0200
libpayload/libc: Fix memset/sizeof usage
Since r is a pointer, memset(r, 0, sizeof(r)) would only zero the first
4 (or 8) bytes of the newly allocated struct align_region_t.
An alternative to this patch would be to use calloc, or introduce a new
zalloc (zeroed allocation; a single-element calloc) and use that.
This fixes Coverity ID 1291160.
Change-Id: Ic3e3487ce749eeebf6c4836e62b8a305ad766e7e
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
---
payloads/libpayload/libc/malloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 7099e47..b7ac1a7 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -366,7 +366,7 @@ static struct align_region_t *allocate_region(int alignment, int num_elements,
if (r == NULL)
return NULL;
- memset(r, 0, sizeof(r));
+ memset(r, 0, sizeof(*r));
if (num_elements != 0) {
r->alignment = alignment;
More information about the coreboot-gerrit
mailing list