]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP: Avoid NULL use with snprintf string
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Wed, 3 Apr 2019 15:17:16 +0000 (18:17 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 6 Apr 2019 15:49:26 +0000 (18:49 +0300)
identity_buf may be NULL here. Handle this case explicitly by printing
"N/A" instead relying on snprintf converting this to "(null)" or some
other value based on unexpected NULL pointer.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/ap/ieee802_1x.c

index a56c82e564e63220aef78456b876111466cf0a5b..870329a859415957dc55e3add189046b80a36f63 100644 (file)
@@ -2733,7 +2733,8 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
                                   wpa_auth_sta_key_mgmt(sta->wpa_sm))) ?
                          1 : 2,
                          (unsigned int) diff.sec,
-                         sm->identity ? (char *) sm->identity : identity_buf);
+                         sm->identity ? (char *) sm->identity :
+                                        (identity_buf ? identity_buf : "N/A"));
        os_free(identity_buf);
        if (os_snprintf_error(buflen - len, ret))
                return len;