HI tech@,

I think maybe one snprintf is more efficient and concise. Sorry if I am
wrong, thanks!

Index: etc.c
===================================================================
RCS file: /cvs/src/libexec/ld.so/ldconfig/etc.c,v
retrieving revision 1.7
diff -u -p -r1.7 etc.c
--- etc.c       12 May 2006 23:35:16 -0000      1.7
+++ etc.c       7 Jun 2018 07:10:30 -0000
@@ -5,6 +5,7 @@
 #include <sys/types.h>

 #include <err.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "ld.h"
@@ -61,9 +62,7 @@ concat(const char *s1, const char *s2, c
        len = strlen(s1) + strlen(s2) + strlen(s3) + 1;
        str = xmalloc(len);

-       strlcpy(str, s1, len);
-       strlcat(str, s2, len);
-       strlcat(str, s3, len);
+       snprintf(str, len, "%s%s%s", s1, s2, s3);

        return (str);
 }

-- 
Best Regards
Nan Xiao

Reply via email to