[coreboot-gerrit] New patch to review for coreboot: lib: Fix strncmp
Hannah Williams (hannah.williams@intel.com)
gerrit at coreboot.org
Tue Dec 15 01:40:28 CET 2015
Hannah Williams (hannah.williams at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12721
-gerrit
commit 2ffab4935c3ce1b284b33c8d746e495f8c0ada1f
Author: Hannah Williams <hannah.williams at intel.com>
Date: Tue Dec 1 09:30:27 2015 -0800
lib: Fix strncmp
strncmp continues to compare the characters in the input strings past any
null termination it may encounter. Null termination check is added.
Reviewed-on: https://chromium-review.googlesource.com/314815
Reviewed-by: Aaron Durbin <adurbin at chromium.org>
Commit-Queue: Hannah Williams <hannah.williams at intel.com>
Tested-by: Hannah Williams <hannah.williams at intel.com>
(cherry picked from commit ca7022752115eddbcb776f0c0d778249555ddf32)
Reviewed-on: https://chromium-review.googlesource.com/315130
Change-Id: Ifc378966dcf6023efe3d32b026cc89d69b0bb990
Signed-off-by: Hannah Williams <hannah.williams at intel.com>
---
src/include/string.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/include/string.h b/src/include/string.h
index b862194..125c676 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -112,7 +112,7 @@ static inline int strncmp(const char *s1, const char *s2, int maxlen)
int i;
for (i = 0; i < maxlen; i++) {
- if (s1[i] != s2[i])
+ if ((s1[i] != s2[i]) || (s1[i] == '\0'))
return s1[i] - s2[i];
}
More information about the coreboot-gerrit
mailing list