]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use os_strdup() instead of os_malloc() + os_memcpy()
authorJouni Malinen <j@w1.fi>
Sun, 19 Aug 2012 15:50:42 +0000 (18:50 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 19 Aug 2012 15:50:42 +0000 (18:50 +0300)
It is simpler to use os_strdup() to copy strings even if the end results
end up being used as binary data with a separate length field.

Signed-hostap: Jouni Malinen <j@w1.fi>

hostapd/config_file.c

index c3c2f73da57ea34463a2316b21075d8fce678ef5..c2804b9057505a6ec8ef20f5ea44afba00264251 100644 (file)
@@ -567,25 +567,21 @@ static int hostapd_parse_das_client(struct hostapd_bss_config *bss,
                                    const char *val)
 {
        char *secret;
-       size_t len;
 
        secret = os_strchr(val, ' ');
        if (secret == NULL)
                return -1;
 
        secret++;
-       len = os_strlen(secret);
 
        if (hostapd_parse_ip_addr(val, &bss->radius_das_client_addr))
                return -1;
 
        os_free(bss->radius_das_shared_secret);
-       bss->radius_das_shared_secret = os_malloc(len);
+       bss->radius_das_shared_secret = (u8 *) os_strdup(secret);
        if (bss->radius_das_shared_secret == NULL)
                return -1;
-
-       os_memcpy(bss->radius_das_shared_secret, secret, len);
-       bss->radius_das_shared_secret_len = len;
+       bss->radius_das_shared_secret_len = os_strlen(secret);
 
        return 0;
 }