From e495212d229d58eb4d70c94d7f828a04c386c3b2 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 4 Jan 2017 23:47:07 +1030 Subject: Sync libiberty from gcc Picks up copyright year update and other recent fixes. --- libiberty/strndup.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'libiberty/strndup.c') diff --git a/libiberty/strndup.c b/libiberty/strndup.c index 9e9b4e2..0a4cda4 100644 --- a/libiberty/strndup.c +++ b/libiberty/strndup.c @@ -1,5 +1,5 @@ /* Implement the strndup function. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005-2017 Free Software Foundation, Inc. Written by Kaveh R. Ghazi . This file is part of the libiberty library. @@ -33,7 +33,7 @@ memory was available. The result is always NUL terminated. #include "ansidecl.h" #include -extern size_t strlen (const char*); +extern size_t strnlen (const char *s, size_t maxlen); extern PTR malloc (size_t); extern PTR memcpy (PTR, const PTR, size_t); @@ -41,10 +41,7 @@ char * strndup (const char *s, size_t n) { char *result; - size_t len = strlen (s); - - if (n < len) - len = n; + size_t len = strnlen (s, n); result = (char *) malloc (len + 1); if (!result) -- cgit v1.1