]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
tlsproxy.c: Use strdup() instead of malloc()/perror().
authorSimon Ruderich <simon@ruderich.org>
Sat, 7 Dec 2013 21:34:37 +0000 (22:34 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sat, 7 Dec 2013 21:34:37 +0000 (22:34 +0100)
src/tlsproxy.c

index fa570641b264f87e738f81862f03439bac05b388..9cca1ad506364ba40b03d0efe983b91557ec9dbf 100644 (file)
@@ -317,12 +317,11 @@ static void parse_arguments(int argc, char **argv) {
                 memcpy(global_proxy_host, optarg, (size_t)(position - optarg));
                 global_proxy_host[position - optarg] = '\0';
 
-                global_proxy_port = malloc(strlen(position + 1) + 1);
+                global_proxy_host = strdup(position + 1);
                 if (global_proxy_port == NULL) {
-                    perror("malloc()");
+                    perror("strdup()");
                     exit(EXIT_FAILURE);
                 }
-                strcpy(global_proxy_port, position + 1);
 
                 break;
             }