aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/config.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-12-06 19:40:31 (GMT)
committerJouni Malinen <j@w1.fi>2014-12-08 09:42:07 (GMT)
commit1d399771367e6c26927141ca3bca19ba53584cbb (patch)
tree249803abc46b1a20b97d7f62211b595dd91dd0cf /wpa_supplicant/config.c
parent1f102d3bb0b4621e32d3402a6e42a97a71d707d4 (diff)
downloadhostap-1d399771367e6c26927141ca3bca19ba53584cbb.zip
hostap-1d399771367e6c26927141ca3bca19ba53584cbb.tar.gz
hostap-1d399771367e6c26927141ca3bca19ba53584cbb.tar.bz2
Check os_snprintf() result more consistently
While these are using practically large enoungh buffer sizes, it is better to be more consistent with checking os_snprintf() return value. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/config.c')
-rw-r--r--wpa_supplicant/config.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 786d268..bd80b29 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -358,9 +358,15 @@ static char * wpa_config_write_psk(const struct parse_data *data,
if (ssid->ext_psk) {
size_t len = 4 + os_strlen(ssid->ext_psk) + 1;
char *buf = os_malloc(len);
+ int res;
+
if (buf == NULL)
return NULL;
- os_snprintf(buf, len, "ext:%s", ssid->ext_psk);
+ res = os_snprintf(buf, len, "ext:%s", ssid->ext_psk);
+ if (os_snprintf_error(len, res)) {
+ os_free(buf);
+ buf = NULL;
+ }
return buf;
}
#endif /* CONFIG_EXT_PASSWORD */
@@ -2995,12 +3001,18 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var,
static char * alloc_int_str(int val)
{
+ const unsigned int bufsize = 20;
char *buf;
+ int res;
- buf = os_malloc(20);
+ buf = os_malloc(bufsize);
if (buf == NULL)
return NULL;
- os_snprintf(buf, 20, "%d", val);
+ res = os_snprintf(buf, bufsize, "%d", val);
+ if (os_snprintf_error(bufsize, res)) {
+ os_free(buf);
+ buf = NULL;
+ }
return buf;
}