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
Possibly Parallel Threads
- [PATCH] strndup(): Fix possible null pointer dereference
- [PATCH 0/2] Correct various strndup() problems
- [PATCH 1/3] btrfs-progs: Fix a compile fail by strndup in RHEL5 env
- [PATCH] Btrgs-progs: Define _GNU_SOURCE for strndup
- Patch to replace strndup with malloc/strncpy for the ini plugin
