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@chromium.org> Commit-Queue: Hannah Williams <hannah.williams@intel.com> Tested-by: Hannah Williams <hannah.williams@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@intel.com> Reviewed-on: https://review.coreboot.org/12721 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
fa6014a6ec
commit
03d4ae7684
|
@ -112,7 +112,7 @@ static inline int strncmp(const char *s1, const char *s2, int maxlen)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < maxlen; 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];
|
return s1[i] - s2[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue