diff options
-rw-r--r-- | airpcap.h | 6 | ||||
-rw-r--r-- | airpcap_loader.c | 4 | ||||
-rw-r--r-- | ui/gtk/airpcap_gui_utils.c | 2 |
3 files changed, 7 insertions, 5 deletions
@@ -169,13 +169,13 @@ AirpcapMacAddress, *PAirpcapMacAddress; /*! \brief This structure is used to store a collection of WEP keys. Note that the definition of the structure doesn't contain any key, so be careful to allocate a buffer - with the size of the key, like in the following example: + with the size of the set of keys, as per the following example: \code PAirpcapKeysCollection KeysCollection; guint KeysCollectionSize; - KeysCollectionSize = sizeof(AirpcapKeysCollection) + NumKeys * sizeof(AirpcapKey); + KeysCollectionSize = AirpcapKeysCollectionSize(NumKeys); KeysCollection = (PAirpcapKeysCollection)malloc(KeysCollectionSize); if(!KeysCollection) @@ -190,6 +190,8 @@ typedef struct _AirpcapKeysCollection AirpcapKey Keys[0]; /* < Array of nKeys keys. */ } AirpcapKeysCollection, *PAirpcapKeysCollection; +#define AirpcapKeysCollectionSize(nKeys) (sizeof(AirpcapKeysCollection) + ((nKeys) * sizeof(AirpcapKey))) + /*! \brief Packet header. diff --git a/airpcap_loader.c b/airpcap_loader.c index 3b745823c2..fca1d3179d 100644 --- a/airpcap_loader.c +++ b/airpcap_loader.c @@ -350,7 +350,7 @@ write_wlan_wep_keys_to_registry(airpcap_if_info_t* info_if, GList* key_list) /* * Calculate the size of the keys collection */ - KeysCollectionSize = (guint)(sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey)); + KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list); /* * Allocate the collection @@ -449,7 +449,7 @@ write_wlan_driver_wep_keys_to_registry(GList* key_list) /* * Calculate the size of the keys collection */ - KeysCollectionSize = (guint)(sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey)); + KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list); /* * Allocate the collection diff --git a/ui/gtk/airpcap_gui_utils.c b/ui/gtk/airpcap_gui_utils.c index c33308cde5..fec1ad3594 100644 --- a/ui/gtk/airpcap_gui_utils.c +++ b/ui/gtk/airpcap_gui_utils.c @@ -715,7 +715,7 @@ airpcap_add_keys_to_driver_from_list(GtkListStore *key_list_store, airpcap_if_in /* * Calculate the size of the keys collection */ - KeysCollectionSize = (guint) (sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey)); + KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list); /* * Allocate the collection |