From: Jouni Malinen Date: Tue, 1 Jan 2013 18:26:20 +0000 (+0200) Subject: Use more explicit way of copying pointer value to a buffer X-Git-Tag: aosp-kk-from-upstream~666 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=559cdabb0fed79f70872e1a652a955202699126c;p=thirdparty%2Fhostap.git 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 --- 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;