From 801aa7c355702efe2a6e505d59431980099a1f14 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 26 Mar 2015 13:35:23 -0700 Subject: libpayload: fix a mips memmove() bug size_t is an unsigned type and as such is a bad choice for a counting down loop counter. BRANCH=all BUG=none TEST=editing cli command line does not cause hangs any more Change-Id: I0502553b5e2143052345edeb205a01558fccd9b8 Signed-off-by: Patrick Georgi Original-Commit-Id: 1c171f739497fcd26589976676ab94b23cd7ee8b Original-Change-Id: I4aa38379ac356114fc91a32cced2fa45a00a09d6 Original-Signed-off-by: Vadim Bendebury Original-Reviewed-on: https://chromium-review.googlesource.com/262714 Original-Reviewed-by: Ionela Voinescu Original-Tested-by: Ionela Voinescu Original-Reviewed-by: David Hendricks Reviewed-on: http://review.coreboot.org/9891 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/arch/mips/string.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'payloads/libpayload') diff --git a/payloads/libpayload/arch/mips/string.c b/payloads/libpayload/arch/mips/string.c index 0563cf82ac..6326d15994 100644 --- a/payloads/libpayload/arch/mips/string.c +++ b/payloads/libpayload/arch/mips/string.c @@ -47,11 +47,10 @@ void *memmove(void *dest, const void *src, size_t n) if ((src < dest) && (dest - src < n)) { u8 *ptr_d = dest; const u8 *ptr_s = src; - size_t i; /* copy backwards */ - for (i = n - 1; i >= 0; i--) - ptr_d[i] = ptr_s[i]; + while (n--) + ptr_d[n] = ptr_s[n]; return dest; } -- cgit v1.2.3