[PATCH]: driver_madwifi.c null ptr dereference fix

Ted Merrill ted
Wed Oct 10 15:26:49 PDT 2007


Jouni,

In tracking down a null ptr dereference fix by Atheros engineers 
(separately fixed by others in hostapd), i came across some
possible null pointer dereferences in debugging statements.
Attached is patch.
Probably these are rarely or never executed, but just in case.
You might be inspired to look through the rest of the file for
similar issues... i would but i'm not sure where NULL ptrs would
be expected.
For extra credit, it would be nice if it were documented via comments
whenever an NULL pointer was an acceptable argument value and 
what it meant.

Thanks
Ted Merrill
Atheros Communications

The patch:

diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c
index 0fb0a1e..d1b47f8 100644
--- a/hostapd/driver_madwifi.c
+++ b/hostapd/driver_madwifi.c
@@ -455,8 +455,9 @@ madwifi_del_key(void *priv, const u8 *addr, int key_idx)

        ret = set80211priv(priv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
        if (ret < 0) {
-               wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr " MACSTR
-                          " key_idx %d)", __func__, MAC2STR(addr), key_idx);
+               wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
+                          " key_idx %d)", __func__, ether_sprintf(addr),
+                          key_idx);
        }

        return ret;
@@ -514,10 +515,10 @@ madwifi_set_key(const char *ifname, void *priv, const char
 *alg,

        ret = set80211priv(priv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
        if (ret < 0) {
-               wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr " MACSTR
+               wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
                           " key_idx %d alg '%s' key_len %lu txkey %d)",
-                          __func__, MAC2STR(wk.ik_macaddr), key_idx, alg,
-                          (unsigned long) key_len, txkey);
+                          __func__, ether_sprintf(wk.ik_macaddr), key_idx,
+                          alg, (unsigned long) key_len, txkey);
        }

        return ret;





More information about the Hostap mailing list