svn commit: r252875 - stable/9/sys/boot/common
Andriy Gapon
avg at FreeBSD.org
Sat Jul 6 08:58:30 UTC 2013
Author: avg
Date: Sat Jul 6 08:58:30 2013
New Revision: 252875
URL: http://svnweb.freebsd.org/changeset/base/252875
Log:
MFC r249139: strncmp for boot code: fix an off by one error
Modified:
stable/9/sys/boot/common/util.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/boot/ (props changed)
Modified: stable/9/sys/boot/common/util.c
==============================================================================
--- stable/9/sys/boot/common/util.c Sat Jul 6 08:51:56 2013 (r252874)
+++ stable/9/sys/boot/common/util.c Sat Jul 6 08:58:30 2013 (r252875)
@@ -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
More information about the svn-src-all
mailing list