wlantest: Fix mgmt CCMP decrypt to not crash on failures

This commit is contained in:
Jouni Malinen 2010-11-12 23:28:43 +02:00
parent 2102ecf0b5
commit 42e79f82dc

View file

@ -660,7 +660,7 @@ static u8 * mgmt_ccmp_decrypt(struct wlantest *wt, const u8 *data, size_t len,
struct wlantest_sta *sta; struct wlantest_sta *sta;
const struct ieee80211_hdr *hdr; const struct ieee80211_hdr *hdr;
int keyid; int keyid;
u8 *decrypted, *frame; u8 *decrypted, *frame = NULL;
u8 pn[6], *rsc; u8 pn[6], *rsc;
hdr = (const struct ieee80211_hdr *) data; hdr = (const struct ieee80211_hdr *) data;
@ -697,15 +697,15 @@ static u8 * mgmt_ccmp_decrypt(struct wlantest *wt, const u8 *data, size_t len,
} }
decrypted = ccmp_decrypt(sta->ptk.tk1, hdr, data + 24, len - 24, dlen); decrypted = ccmp_decrypt(sta->ptk.tk1, hdr, data + 24, len - 24, dlen);
if (decrypted) if (decrypted) {
os_memcpy(rsc, pn, 6); os_memcpy(rsc, pn, 6);
frame = os_malloc(24 + *dlen); frame = os_malloc(24 + *dlen);
if (frame) { if (frame) {
os_memcpy(frame, data, 24); os_memcpy(frame, data, 24);
os_memcpy(frame + 24, decrypted, *dlen); os_memcpy(frame + 24, decrypted, *dlen);
*dlen += 24; *dlen += 24;
} }
}
os_free(decrypted); os_free(decrypted);