main: strdup command line arguments that are modified
authorFelix Fietkau <nbd@openwrt.org>
Sat, 22 Mar 2014 19:28:17 +0000 (20:28 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 22 Mar 2014 19:32:29 +0000 (20:32 +0100)
This ensures that the process will show the correct command line in ps

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
main.c

diff --git a/main.c b/main.c
index 99a4025..38d023f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -249,6 +249,7 @@ int main(int argc, char **argv)
                        break;
 #endif
                case 'p':
                        break;
 #endif
                case 'p':
+                       optarg = strdup(optarg);
                        bound += add_listener_arg(optarg, (ch == 's'));
                        break;
 
                        bound += add_listener_arg(optarg, (ch == 's'));
                        break;
 
@@ -305,6 +306,7 @@ int main(int argc, char **argv)
                        break;
 
                case 'i':
                        break;
 
                case 'i':
+                       optarg = strdup(optarg);
                        port = strchr(optarg, '=');
                        if (optarg[0] != '.' || !port) {
                                fprintf(stderr, "Error: Invalid interpreter: %s\n",
                        port = strchr(optarg, '=');
                        if (optarg[0] != '.' || !port) {
                                fprintf(stderr, "Error: Invalid interpreter: %s\n",
@@ -337,6 +339,7 @@ int main(int argc, char **argv)
                        break;
 
                case 'd':
                        break;
 
                case 'd':
+                       optarg = strdup(optarg);
                        port = alloca(strlen(optarg) + 1);
                        if (!port)
                                return -1;
                        port = alloca(strlen(optarg) + 1);
                        if (!port)
                                return -1;