From: Jouni Malinen Date: Sun, 19 Aug 2012 15:50:42 +0000 (+0300) Subject: Use os_strdup() instead of os_malloc() + os_memcpy() X-Git-Tag: hostap_2_0~366 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e4598755be9aebdc0f8feeaee09450180e51e97;p=thirdparty%2Fhostap.git Use os_strdup() instead of os_malloc() + os_memcpy() 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 --- diff --git a/hostapd/config_file.c b/hostapd/config_file.c index c3c2f73da..c2804b905 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -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; }