wpa_cli: Allow space in the set command value

Previously, interactive mode could not be used to enter space-separated
lists with the set command. This removes that restriction and allows
such commands to be encoded properly.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-05-05 11:53:20 +03:00
parent f5ffc348dc
commit f1fb042cec

View file

@ -590,22 +590,16 @@ static int wpa_cli_cmd_set(struct wpa_ctrl *ctrl, int argc, char *argv[])
return 0; return 0;
} }
if (argc != 1 && argc != 2) { if (argc == 1) {
printf("Invalid SET command: needs two arguments (variable " res = os_snprintf(cmd, sizeof(cmd), "SET %s ", argv[0]);
"name and value)\n"); if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
return -1; printf("Too long SET command.\n");
return -1;
}
return wpa_ctrl_command(ctrl, cmd);
} }
if (argc == 1) return wpa_cli_cmd(ctrl, "SET", 2, argc, argv);
res = os_snprintf(cmd, sizeof(cmd), "SET %s ", argv[0]);
else
res = os_snprintf(cmd, sizeof(cmd), "SET %s %s",
argv[0], argv[1]);
if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
printf("Too long SET command.\n");
return -1;
}
return wpa_ctrl_command(ctrl, cmd);
} }