diff options
author | cognet <cognet@FreeBSD.org> | 2009-04-28 19:20:13 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2009-04-28 19:20:13 +0000 |
commit | 98bad5286975a431e248f82fe967596915b1e2f1 (patch) | |
tree | 370020ceb5ec0a0728b9b03ddbbe784caaece742 | |
parent | dadda39aa26fb247fa1de1bdec3dbc7129f35b3f (diff) | |
download | FreeBSD-src-98bad5286975a431e248f82fe967596915b1e2f1.zip FreeBSD-src-98bad5286975a431e248f82fe967596915b1e2f1.tar.gz |
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>
-rw-r--r-- | lib/libc/arm/string/strncmp.S | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/arm/string/strncmp.S b/lib/libc/arm/string/strncmp.S index d172264..5a2c422 100644 --- a/lib/libc/arm/string/strncmp.S +++ b/lib/libc/arm/string/strncmp.S @@ -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 |