From de6b062321f6631c49119190dc63b00a566148df Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 28 Jun 1996 11:42:05 +0000 Subject: Fri Jun 28 07:27:10 1996 Roland McGrath * string/strndup.c (strndup): Always terminate the string. * string/string.h (strndupa): Likewise. Thu Jun 27 14:22:31 1996 Andreas Schwab * stdio/Makefile (routines): Add vscanf. * stdio-common/Makefile (routines): Remove vscanf. * stdio-common/vscanf.c: Move to ... * stdio/vscanf.c: here. * rpm/Makefile (headers, install-lib, install-lib.so, versioned, install-bin, install-sbin, install-data, install-others): Add $(-VARIABLE). --- string/strndup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'string/strndup.c') diff --git a/string/strndup.c b/string/strndup.c index 213a0c056b..c40d00fc59 100644 --- a/string/strndup.c +++ b/string/strndup.c @@ -24,13 +24,14 @@ Cambridge, MA 02139, USA. */ char * strndup (const char *s, size_t n) { - size_t len = strnlen (s) + 1; - char *new = malloc (len); + size_t len = strnlen (s); + char *new = malloc (len + 1); if (new == NULL) return NULL; memcpy (new, s, len); + new[len] = '\0'; return new; } -- cgit v1.2.3