Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/libbb/safe_strncpy.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/libbb/safe_strncpy.c
r821 r1770 8 8 */ 9 9 10 #include <string.h>11 10 #include "libbb.h" 12 13 14 11 15 12 /* Like strncpy but make sure the resulting string is always 0 terminated. */ 16 13 char * safe_strncpy(char *dst, const char *src, size_t size) 17 14 { 18 dst[size-1] = '\0'; 19 return strncpy(dst, src, size-1); 15 if (!size) return dst; 16 dst[--size] = '\0'; 17 return strncpy(dst, src, size); 20 18 }
Note:
See TracChangeset
for help on using the changeset viewer.