]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Do not require dpp_configurator_params to start with a space
authorJouni Malinen <jouni@codeaurora.org>
Tue, 11 Feb 2020 04:41:33 +0000 (06:41 +0200)
committerJouni Malinen <jouni@codeaurora.org>
Tue, 11 Feb 2020 04:43:02 +0000 (06:43 +0200)
This ugly hack for being able to search for optional arguments with
space before them was quite inconvenient and unexpected. Clean this up
by handling this mess internally with a memory allocation and string
duplication if needed so that the users of wpa_supplicant control
interface do not need to care about such details.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/common/dpp.c

index 7152703e69e5e445504a3d1f5f3f9dfd9efef8cf..b200d00daef830316e109a5aeae60fe29c86d5b2 100644 (file)
@@ -4680,9 +4680,22 @@ int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
                         const char *cmd)
 {
        const char *pos;
+       char *tmp = NULL;
+       int ret = -1;
 
        if (!cmd)
                return 0;
+       if (cmd[0] != ' ') {
+               size_t len;
+
+               len = os_strlen(cmd);
+               tmp = os_malloc(len + 2);
+               if (!tmp)
+                       goto fail;
+               tmp[0] = ' ';
+               os_memcpy(tmp + 1, cmd, len + 1);
+               cmd = tmp;
+       }
 
        wpa_printf(MSG_DEBUG, "DPP: Set configurator parameters: %s", cmd);
 
@@ -4693,7 +4706,7 @@ int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
                if (!auth->conf) {
                        wpa_printf(MSG_INFO,
                                   "DPP: Could not find the specified configurator");
-                       return -1;
+                       goto fail;
                }
        }
 
@@ -4712,9 +4725,12 @@ int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
        if (dpp_configuration_parse(auth, cmd) < 0) {
                wpa_msg(msg_ctx, MSG_INFO,
                        "DPP: Failed to set configurator parameters");
-               return -1;
+               goto fail;
        }
-       return 0;
+       ret = 0;
+fail:
+       os_free(tmp);
+       return ret;
 }