Date: Tue, 28 Apr 2009 19:20:13 +0000 (UTC) From: Olivier Houchard <cognet@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r191633 - head/lib/libc/arm/string Message-ID: <200904281920.n3SJKDMZ057702@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cognet Date: Tue Apr 28 19:20:13 2009 New Revision: 191633 URL: http://svn.freebsd.org/changeset/base/191633 Log: Change the test at the beginning of strncmp(), from being if (len - 1) < 0 to if (len == 0). The length is supposed to be unsigned, so len - 1 < 0 won't happen except if len == 0 anyway, and it would return 0 when it shouldn't, if len was > INT_MAX. Spotted out by: Channa <channa kad gmail com> Modified: head/lib/libc/arm/string/strncmp.S Modified: head/lib/libc/arm/string/strncmp.S ============================================================================== --- head/lib/libc/arm/string/strncmp.S Tue Apr 28 17:41:52 2009 (r191632) +++ head/lib/libc/arm/string/strncmp.S Tue Apr 28 19:20:13 2009 (r191633) @@ -33,10 +33,10 @@ __FBSDID("$FreeBSD$"); ENTRY(strncmp) -/* if ((len - 1) < 0) return 0 */ - subs r2, r2, #1 - movmi r0, #0 - movmi pc, lr +/* if (len == 0) return 0 */ + cmp r2, #0 + moveq r0, #0 + RETeq /* ip == last src address to compare */ add ip, r0, r2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904281920.n3SJKDMZ057702>