Hi,

xstrdup just wrappes strdup, so there is no need to call xmalloc and
strlcpy instead.

Regards,
--F.


 
Index: xmalloc.c
===================================================================
RCS file: /cvs/src/usr.bin/rcs/xmalloc.c,v
retrieving revision 1.8
diff -u -p -r1.8 xmalloc.c
--- xmalloc.c   26 Mar 2015 15:17:30 -0000      1.8
+++ xmalloc.c   19 May 2015 18:54:22 -0000
@@ -76,13 +76,11 @@ xfree(void *ptr)
 char *
 xstrdup(const char *str)
 {
-       size_t len;
        char *cp;
 
-       len = strlen(str) + 1;
-       cp = xmalloc(len);
-       if (strlcpy(cp, str, len) >= len)
-               errx(1, "xstrdup: string truncated");
+       if ((cp = strdup(str)) == NULL)
+               errx(1, "xstrdup: copy string failed");
+
        return cp;
 }
 

Attachment: pgpsSRRSWzADK.pgp
Description: PGP signature

Reply via email to