malloc + strlcpy -> strdup
authorderaadt <deraadt@openbsd.org>
Sat, 19 Apr 2014 12:36:03 +0000 (12:36 +0000)
committerderaadt <deraadt@openbsd.org>
Sat, 19 Apr 2014 12:36:03 +0000 (12:36 +0000)
lib/libssl/src/apps/s_socket.c

index 57015ed..d52714c 100644 (file)
@@ -302,11 +302,10 @@ redoit:
                *host = NULL;
                /* return(0); */
        } else {
-               if ((*host = (char *) malloc(strlen(h1->h_name) + 1)) == NULL) {
-                       perror("malloc");
+               if ((*host = strdup(h1->h_name) == NULL) {
+                       perror("strdup");
                        return (0);
                }
-               strlcpy(*host, h1->h_name, strlen(h1->h_name) + 1);
 
                h2 = GetHostByName(*host);
                if (h2 == NULL) {