From 6062c0d19bc201cbeb61b8875598cdd7a14a5ae0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 5 Jan 2022 23:02:13 +0100 Subject: libbb: change xstrndup, xmemdup to take size_t as size parameter Also, remove entirely usually-disabled paranoia check (was also using wrong config option to enable itself). Signed-off-by: Denys Vlasenko --- libbb/xfuncs_printf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index d29aceb..fc630d1 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -91,13 +91,10 @@ char* FAST_FUNC xstrdup(const char *s) // Die if we can't allocate n+1 bytes (space for the null terminator) and copy // the (possibly truncated to length n) string into it. -char* FAST_FUNC xstrndup(const char *s, int n) +char* FAST_FUNC xstrndup(const char *s, size_t n) { char *t; - if (ENABLE_DEBUG && s == NULL) - bb_simple_error_msg_and_die("xstrndup bug"); - t = strndup(s, n); if (t == NULL) @@ -106,7 +103,7 @@ char* FAST_FUNC xstrndup(const char *s, int n) return t; } -void* FAST_FUNC xmemdup(const void *s, int n) +void* FAST_FUNC xmemdup(const void *s, size_t n) { return memcpy(xmalloc(n), s, n); } -- cgit v1.1