aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2018-12-23 22:44:36 (GMT)
committerJouni Malinen <j@w1.fi>2018-12-24 09:09:22 (GMT)
commite422a819d0fded76085c8d12e7b978202d3ed76e (patch)
tree5a1bc237d78b167a55953af34215c94ea59e0bbc /wpa_supplicant
parentee98dd631aa699759e77170f5a9bf07b28b00005 (diff)
downloadhostap-e422a819d0fded76085c8d12e7b978202d3ed76e.zip
hostap-e422a819d0fded76085c8d12e7b978202d3ed76e.tar.gz
hostap-e422a819d0fded76085c8d12e7b978202d3ed76e.tar.bz2
Check snprintf result to avoid compiler warnings
These do not really get truncated in practice, but it looks like some newer compilers warn about the prints, so silence those by checking the result and do something a bit more useful if the output would actually get truncated. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c8
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_wps.c8
-rw-r--r--wpa_supplicant/dbus/dbus_old_handlers_wps.c8
3 files changed, 19 insertions, 5 deletions
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 9305b9a..33f02a7 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -532,6 +532,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
int new_pin;
char *err_msg = NULL;
char *iface = NULL;
+ int ret;
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
return reply;
@@ -609,7 +610,12 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
char npin[9];
char *generated_pin;
- os_snprintf(npin, sizeof(npin), "%08d", new_pin);
+ ret = os_snprintf(npin, sizeof(npin), "%08d", new_pin);
+ if (os_snprintf_error(sizeof(npin), ret)) {
+ reply = wpas_dbus_error_unknown_error(message,
+ "invalid PIN");
+ goto out;
+ }
generated_pin = npin;
reply = dbus_message_new_method_return(message);
dbus_message_append_args(reply, DBUS_TYPE_STRING,
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
index f762b3f..19c1a61 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
@@ -286,8 +286,12 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
ret = wpas_wps_start_pin(wpa_s, params.bssid,
params.pin, 0,
DEV_PW_DEFAULT);
- if (ret > 0)
- os_snprintf(npin, sizeof(npin), "%08d", ret);
+ if (ret > 0) {
+ ret = os_snprintf(npin, sizeof(npin), "%08d", ret);
+ if (os_snprintf_error(sizeof(npin), ret))
+ return wpas_dbus_error_unknown_error(
+ message, "invalid PIN");
+ }
} else {
ret = wpas_wps_start_pbc(wpa_s, params.bssid, 0);
}
diff --git a/wpa_supplicant/dbus/dbus_old_handlers_wps.c b/wpa_supplicant/dbus/dbus_old_handlers_wps.c
index 5309a53..987e12d 100644
--- a/wpa_supplicant/dbus/dbus_old_handlers_wps.c
+++ b/wpa_supplicant/dbus/dbus_old_handlers_wps.c
@@ -71,7 +71,7 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
char *arg_bssid;
char *pin = NULL;
u8 bssid[ETH_ALEN], *_bssid = NULL;
- int ret = 0;
+ int ret;
char npin[9];
if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
@@ -105,7 +105,11 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
return NULL;
if (ret > 0) {
- os_snprintf(npin, sizeof(npin), "%08d", ret);
+ ret = os_snprintf(npin, sizeof(npin), "%08d", ret);
+ if (os_snprintf_error(sizeof(npin), ret))
+ return wpas_dbus_new_invalid_opts_error(message,
+ "invalid PIN");
+
pin = npin;
}
dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin,