Re: bugs in strlen, strstr setlocale -- i386
Nikola Vladov <[email protected]>
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Apr 05, 2009 at 02:01:18AM +0200, Laurent Bercot wrote:
> A fix is indeed needed... on architectures where strlen(NULL) returns
> something valid. strlen(NULL) should crash on every architecture.
I'm agree. So is better! Here is a "fix" for i386
If strlen(NULL) fails, then stsstr() fails with NULL args also!
vladov@/tmp$ diet -Os gcc -Wall -c strlen.S
vladov@/tmp$ size strlen.o
text data bss dec hex filename
15 0 0 15 f strlen.o
vladov@/tmp$ size /opt/diet/lib-i386/libc.a | grep strlen
17 0 0 17 11 strlen.o (ex /opt/diet/lib-i386/libc.a)
------------------------
.globl strlen
.type strlen, @function
strlen:
movl 4(%esp), %ecx
orl $-1, %eax
.L1:
incl %eax
cmpb $0, (%ecx, %eax)
jne .L1
ret