[coreboot-gerrit] Change in coreboot[master]: libpayload: Fix unaligned buffer logic in default_memset
Marshall Dawson (Code Review)
gerrit at coreboot.org
Thu Jul 20 00:20:24 CEST 2017
Marshall Dawson has uploaded this change for review. ( https://review.coreboot.org/20655
Change subject: libpayload: Fix unaligned buffer logic in default_memset
......................................................................
libpayload: Fix unaligned buffer logic in default_memset
Fix an issue when setting an unaligned buffer where n is less
than the difference of the rounded up pointer and the pointer.
This was identified where n=1 was passed. n was decremented
once, as expected, then decremented again after the while()
evaluated to false. This resulted in a new n of 4GB.
Change-Id: I862671bbe7efa8d370d0148e22ea55407e260053
Signed-off-by: Marshall Dawson <marshalldawson3rd at gmail.com>
---
M payloads/libpayload/libc/memory.c
1 file changed, 3 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/20655/1
diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c
index 2c44764..8d0172c 100644
--- a/payloads/libpayload/libc/memory.c
+++ b/payloads/libpayload/libc/memory.c
@@ -41,8 +41,10 @@
u8 *p = s;
s = (void *)ALIGN_UP((uintptr_t)s, sizeof(unsigned long));
- while (p != (u8 *)s && n--)
+ while (p != (u8 *)s && n) {
*p++ = c;
+ n--;
+ }
for (i = 1; i < sizeof(unsigned long); i <<= 1)
w = (w << (i * 8)) | w;
--
To view, visit https://review.coreboot.org/20655
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I862671bbe7efa8d370d0148e22ea55407e260053
Gerrit-Change-Number: 20655
Gerrit-PatchSet: 1
Gerrit-Owner: Marshall Dawson <marshalldawson3rd at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170719/81cc9478/attachment.html>
More information about the coreboot-gerrit
mailing list