]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_cli: Make second argument to set command optional
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 5 Oct 2011 14:29:51 +0000 (17:29 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 16 Oct 2011 20:55:34 +0000 (23:55 +0300)
This can be used to indicate zero length value.

wpa_supplicant/wpa_cli.c

index 943985671e1ad8b3194f9d4d152514ee417ae977..7a0fdf8b6078349967a7a512cfa37cdbd966c15c 100644 (file)
@@ -381,13 +381,17 @@ static int wpa_cli_cmd_set(struct wpa_ctrl *ctrl, int argc, char *argv[])
                return 0;
        }
 
-       if (argc != 2) {
+       if (argc != 1 && argc != 2) {
                printf("Invalid SET command: needs two arguments (variable "
                       "name and value)\n");
                return -1;
        }
 
-       res = os_snprintf(cmd, sizeof(cmd), "SET %s %s", argv[0], argv[1]);
+       if (argc == 1)
+               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;