aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-10-07 14:24:56 +0200
committerGuy Harris <guy@alum.mit.edu>2015-12-21 12:42:21 +0000
commit30658294265790af21896b93267384d5a8229bad (patch)
tree0bee2df130a2101f7fd68c5a2b2943bc9b8be01d
parentbb3c2e5b99d6896f49cd18b879475c8078482e19 (diff)
downloadwireshark-30658294265790af21896b93267384d5a8229bad.tar.gz
wireshark-30658294265790af21896b93267384d5a8229bad.tar.bz2
wireshark-30658294265790af21896b93267384d5a8229bad.zip
airpdcap: add free_key_string function, fix memleaks
Do not leak the key and SSID. Note that there are still some leaks in the GTK UI related to get_wireshark_keys(), but I did not track them down. Caught by LeakSanitizer. Change-Id: I91308a9cd5d91d601bc778bdf10bfae8254ad2af Reviewed-on: https://code.wireshark.org/review/12792 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--debian/libwireshark5.symbols1
-rw-r--r--epan/crypt/airpdcap.c10
-rw-r--r--epan/crypt/airpdcap_user.h11
-rw-r--r--epan/dissectors/packet-ieee80211.c1
4 files changed, 22 insertions, 1 deletions
diff --git a/debian/libwireshark5.symbols b/debian/libwireshark5.symbols
index 617d7e1f37..45917c1f28 100644
--- a/debian/libwireshark5.symbols
+++ b/debian/libwireshark5.symbols
@@ -542,6 +542,7 @@ libwireshark.so.5 libwireshark5 #MINVER#
frame_data_set_after_dissect@Base 1.9.1
frame_data_set_before_dissect@Base 1.9.1
free_frame_data_sequence@Base 1.12.0~rc1
+ free_key_string@Base 2.0.0~rc1
ftype_can_contains@Base 1.9.1
ftype_can_eq@Base 1.9.1
ftype_can_ge@Base 1.9.1
diff --git a/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c
index d1bf62391e..b77d03e7e2 100644
--- a/epan/crypt/airpdcap.c
+++ b/epan/crypt/airpdcap.c
@@ -1946,6 +1946,16 @@ parse_key_string(gchar* input_string, guint8 key_type)
return NULL;
}
+void
+free_key_string(decryption_key_t *dk)
+{
+ if (dk->key)
+ g_string_free(dk->key, TRUE);
+ if (dk->ssid)
+ g_byte_array_free(dk->ssid, TRUE);
+ g_free(dk);
+}
+
/*
* Returns a newly allocated string representing the given decryption_key_t
* struct, or NULL if something is wrong...
diff --git a/epan/crypt/airpdcap_user.h b/epan/crypt/airpdcap_user.h
index d2ac85dd9b..aeca3f08c4 100644
--- a/epan/crypt/airpdcap_user.h
+++ b/epan/crypt/airpdcap_user.h
@@ -211,7 +211,7 @@ typedef struct _AIRPDCAP_KEYS_COLLECTION {
* - AIRPDCAP_KEY_TYPE_WPA_PSK (WPA + 256-bit raw key)
* @return A pointer to a freshly-g_malloc()ed decryption_key_t struct on
* success, or NULL on failure.
- * @see get_key_string()
+ * @see get_key_string(), free_key_string()
*/
WS_DLL_PUBLIC
decryption_key_t*
@@ -228,6 +228,15 @@ WS_DLL_PUBLIC
gchar*
get_key_string(decryption_key_t* dk);
+/**
+ * Releases memory associated with a given decryption_key_t struct.
+ * @param dk [IN] Pointer to the key to be freed
+ * @see parse_key_string()
+ */
+WS_DLL_PUBLIC
+void
+free_key_string(decryption_key_t *dk);
+
/******************************************************************************/
#endif /* _AIRPDCAP_USER_H */
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index d6b4b02869..d87519cb2c 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -18160,6 +18160,7 @@ set_airpdcap_keys(void)
keys->nKeys += 1;
}
}
+ free_key_string(dk);
}
}