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 <pgeorgi@chromium.org>
Original-Commit-Id: 1c171f739497fcd26589976676ab94b23cd7ee8b
Original-Change-Id: I4aa38379ac356114fc91a32cced2fa45a00a09d6
Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/262714
Original-Reviewed-by: Ionela Voinescu <ionela.voinescu@imgtec.com>
Original-Tested-by: Ionela Voinescu <ionela.voinescu@imgtec.com>
Original-Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/9891
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Vadim Bendebury 2015-03-26 13:35:23 -07:00 committed by Patrick Georgi
parent ee426cf54e
commit 801aa7c355
1 changed files with 2 additions and 3 deletions

View File

@ -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;
}