]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Check os_snprintf() result more consistently - more checks
authorJouni Malinen <j@w1.fi>
Sun, 7 Dec 2014 13:45:02 +0000 (15:45 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 8 Dec 2014 09:42:07 +0000 (11:42 +0200)
Add more os_snprintf() result validation checks.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/sta_info.c
wpa_supplicant/ap.c
wpa_supplicant/ctrl_iface.c

index 02d662603d818a00b4d7ab3715dbe8c627b527ce..debdc067641608b5b32a07a87250d3d8dd3d097d 100644 (file)
@@ -1120,6 +1120,8 @@ int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen)
                          (flags & WLAN_STA_VHT ? "[VHT]" : ""),
                          (flags & WLAN_STA_WNM_SLEEP_MODE ?
                           "[WNM_SLEEP_MODE]" : ""));
+       if (os_snprintf_error(buflen, res))
+               res = -1;
 
        return res;
 }
index 0e6769b672f3454ab5fe18186ebf988b45033a9f..8c3d3b8299e9c1d799dbbfbbd1808cd6d1632f82 100644 (file)
@@ -812,9 +812,14 @@ int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
        if (pin == NULL) {
                unsigned int rpin = wps_generate_pin();
                ret_len = os_snprintf(buf, buflen, "%08d", rpin);
+               if (os_snprintf_error(buflen, ret_len))
+                       return -1;
                pin = buf;
-       } else
+       } else if (buf) {
                ret_len = os_snprintf(buf, buflen, "%s", pin);
+               if (os_snprintf_error(buflen, ret_len))
+                       return -1;
+       }
 
        ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
                                  timeout);
index 9e1fb291c2b47b4b794fa7e88b7258c9d8e59a2f..abf5f522a06e3e49a1c311d3131c3c77191b8b44 100644 (file)
@@ -5859,6 +5859,8 @@ static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, char *cmd,
                        }
                }
                ret = os_snprintf(buf, buflen, "%s\n", "OK");
+               if (os_snprintf_error(buflen, ret))
+                       ret = -1;
        }
        return ret;
 }