Date: Sat, 6 Jul 2013 08:59:27 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r252876 - stable/8/sys/boot/common Message-ID: <201307060859.r668xRkt092433@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Sat Jul 6 08:59:27 2013 New Revision: 252876 URL: http://svnweb.freebsd.org/changeset/base/252876 Log: MFC r249139: strncmp for boot code: fix an off by one error Modified: stable/8/sys/boot/common/util.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/boot/ (props changed) Modified: stable/8/sys/boot/common/util.c ============================================================================== --- stable/8/sys/boot/common/util.c Sat Jul 6 08:58:30 2013 (r252875) +++ stable/8/sys/boot/common/util.c Sat Jul 6 08:59:27 2013 (r252876) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307060859.r668xRkt092433>