Forráskód Böngészése

Add strdup to start-stop-daemon

Wichert Akkerman 27 éve
szülő
commit
b3b861c1ac
1 módosított fájl, 4 hozzáadás és 1 törlés
  1. 4 1
      utils/start-stop-daemon.c

+ 4 - 1
utils/start-stop-daemon.c

@@ -311,7 +311,10 @@ parse_options(int argc, char * const *argv)
 			execname = optarg;
 			execname = optarg;
 			break;
 			break;
 		case 'c':  /* --chuid <username>|<uid> */
 		case 'c':  /* --chuid <username>|<uid> */
-			changeuser = strtok(optarg, ":");
+			/* we copy the string just in case we need the
+			 * argument later. */
+			changeuser = strdup(optarg);
+			changeuser = strtok(changeuser, ":");
 			changegroup = strtok(NULL, ":");
 			changegroup = strtok(NULL, ":");
 			break;
 			break;
 		case 'b':  /* --background */
 		case 'b':  /* --background */