aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h4
-rw-r--r--libbb/xfuncs_printf.c7
2 files changed, 4 insertions, 7 deletions
diff --git a/include/libbb.h b/include/libbb.h
index c93058f6d..daa310776 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -429,8 +429,8 @@ void *xrealloc(void *old, size_t size) FAST_FUNC;
429 xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) 429 xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
430void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; 430void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;
431char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; 431char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
432char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; 432char *xstrndup(const char *s, size_t n) FAST_FUNC RETURNS_MALLOC;
433void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC; 433void *xmemdup(const void *s, size_t n) FAST_FUNC RETURNS_MALLOC;
434void *mmap_read(int fd, size_t size) FAST_FUNC; 434void *mmap_read(int fd, size_t size) FAST_FUNC;
435void *mmap_anon(size_t size) FAST_FUNC; 435void *mmap_anon(size_t size) FAST_FUNC;
436void *xmmap_anon(size_t size) FAST_FUNC; 436void *xmmap_anon(size_t size) FAST_FUNC;
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index d29acebcd..fc630d176 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -91,13 +91,10 @@ char* FAST_FUNC xstrdup(const char *s)
91 91
92// Die if we can't allocate n+1 bytes (space for the null terminator) and copy 92// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
93// the (possibly truncated to length n) string into it. 93// the (possibly truncated to length n) string into it.
94char* FAST_FUNC xstrndup(const char *s, int n) 94char* FAST_FUNC xstrndup(const char *s, size_t n)
95{ 95{
96 char *t; 96 char *t;
97 97
98 if (ENABLE_DEBUG && s == NULL)
99 bb_simple_error_msg_and_die("xstrndup bug");
100
101 t = strndup(s, n); 98 t = strndup(s, n);
102 99
103 if (t == NULL) 100 if (t == NULL)
@@ -106,7 +103,7 @@ char* FAST_FUNC xstrndup(const char *s, int n)
106 return t; 103 return t;
107} 104}
108 105
109void* FAST_FUNC xmemdup(const void *s, int n) 106void* FAST_FUNC xmemdup(const void *s, size_t n)
110{ 107{
111 return memcpy(xmalloc(n), s, n); 108 return memcpy(xmalloc(n), s, n);
112} 109}