From 559cdabb0fed79f70872e1a652a955202699126c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 1 Jan 2013 20:26:20 +0200 Subject: [PATCH] Use more explicit way of copying pointer value to a buffer The code initializing GMK Counter uses the group pointer value as extra entropy and to distinguish different group instances. Some static analyzers complain about the sizeof(pointer) with memcpy, so use a more explicit type casting to make it more obvious what the code is doing. Signed-hostap: Jouni Malinen --- src/ap/wpa_auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index 2c70149a1..fa4b1cb39 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -282,8 +282,9 @@ static void wpa_auth_pmksa_free_cb(struct rsn_pmksa_cache_entry *entry, static int wpa_group_init_gmk_and_counter(struct wpa_authenticator *wpa_auth, struct wpa_group *group) { - u8 buf[ETH_ALEN + 8 + sizeof(group)]; + u8 buf[ETH_ALEN + 8 + sizeof(unsigned long)]; u8 rkey[32]; + unsigned long ptr; if (random_get_bytes(group->GMK, WPA_GMK_LEN) < 0) return -1; @@ -295,7 +296,8 @@ static int wpa_group_init_gmk_and_counter(struct wpa_authenticator *wpa_auth, */ os_memcpy(buf, wpa_auth->addr, ETH_ALEN); wpa_get_ntp_timestamp(buf + ETH_ALEN); - os_memcpy(buf + ETH_ALEN + 8, &group, sizeof(group)); + ptr = (unsigned long) group; + os_memcpy(buf + ETH_ALEN + 8, &ptr, sizeof(ptr)); if (random_get_bytes(rkey, sizeof(rkey)) < 0) return -1;