From 154931c66fcc70424a10f3c99f63e361538cd888 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 16 Aug 2010 18:04:13 +0000 Subject: Fix strcmp and strncmp. They failed in several important scenarios Signed-off-by: Patrick Georgi Acked-by: Patrick Georgi git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5700 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- payloads/libpayload/libc/string.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c index 1ca8bc12e8..7bf19ace37 100644 --- a/payloads/libpayload/libc/string.c +++ b/payloads/libpayload/libc/string.c @@ -91,7 +91,7 @@ int strcasecmp(const char *s1, const char *s2) { int i; - for (i = 0; 1; i++) { + for (i = 0; s1[i] != '\0'; i++) { if (tolower(s1[i]) != tolower(s2[i])) return s1[i] - s2[i]; } @@ -116,7 +116,7 @@ int strncasecmp(const char *s1, const char *s2, size_t maxlen) return s1[i] - s2[i]; } - return 0; + return s1[i] - s2[i]; } /** @@ -132,12 +132,12 @@ int strcmp(const char *s1, const char *s2) { int i; - for (i = 0; 1; i++) { + for (i = 0; s1[i] != '\0'; i++) { if (s1[i] != s2[i]) return s1[i] - s2[i]; } - return 0; + return s1[i] - s2[i]; } /** -- cgit v1.2.3