[klibc] strndup.c bug ?
罗 翼
luoyi_ly82 at yahoo.com.cn
Fri Mar 30 00:24:41 PDT 2007
luoyi at test:~/src/klibc.orig/klibc-1.5/usr/klibc$ diff
-u strndup.c strndup.c.new
--- strndup.c 2007-03-04 09:52:10.000000000 +0800
+++ strndup.c.new 2007-03-29 18:26:29.000000000
+0800
@@ -10,8 +10,9 @@
int l = n > strlen(s) ? strlen(s) + 1 : n + 1;
char *d = malloc(l);
- if (d)
+ if (d) {
memcpy(d, s, l);
- d[n] = '\0';
+ d[l-1] = '\0';
+ }
return d;
}
___________________________________________________________
Mp3疯狂搜-新歌热歌高速下
http://music.yahoo.com.cn/?source=mail_mailbox_footer
More information about the klibc
mailing list