diff options
Diffstat (limited to 'sys/boot/common/util.c')
-rw-r--r-- | sys/boot/common/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/boot/common/util.c b/sys/boot/common/util.c index 07f69a3..21834be 100644 --- a/sys/boot/common/util.c +++ b/sys/boot/common/util.c @@ -68,9 +68,9 @@ int strncmp(const char *s1, const char *s2, size_t len) { - for (; *s1 == *s2 && *s1 != '\0' && len > 0; len--, s1++, s2++) + for (; len > 0 && *s1 == *s2 && *s1 != '\0'; len--, s1++, s2++) ; - return ((unsigned char)*s1 - (unsigned char)*s2); + return (len == 0 ? 0 : (unsigned char)*s1 - (unsigned char)*s2); } void |