diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2017-06-04 12:48:43 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2017-06-04 12:48:43 +0000 |
commit | b876f437ebc3b9e8eeb8ad64763318b388e2a88a (patch) | |
tree | b94c2c16eeeadf03f7e7e68dd92f09f2d81dd7b8 /sys/net80211/ieee80211_input.c | |
parent | 14db7374557de2389271ae05bccbbbf779e96c1c (diff) |
Add sizes for free for the RSN IEs. Rewrite ieee80211_save_ie() slightly
to make it more readable.
help, many explanations and ok stsp
Diffstat (limited to 'sys/net80211/ieee80211_input.c')
-rw-r--r-- | sys/net80211/ieee80211_input.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 2b349bd95fb..ec7fcef9650 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_input.c,v 1.193 2017/06/03 15:44:03 tb Exp $ */ +/* $OpenBSD: ieee80211_input.c,v 1.194 2017/06/04 12:48:42 tb Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe @@ -1362,14 +1362,17 @@ ieee80211_parse_wpa(struct ieee80211com *ic, const u_int8_t *frm, int ieee80211_save_ie(const u_int8_t *frm, u_int8_t **ie) { - if (*ie == NULL || (*ie)[1] != frm[1]) { + int olen = *ie ? 2 + (*ie)[1] : 0; + int len = 2 + frm[1]; + + if (*ie == NULL || olen != len) { if (*ie != NULL) - free(*ie, M_DEVBUF, 0); - *ie = malloc(2 + frm[1], M_DEVBUF, M_NOWAIT); + free(*ie, M_DEVBUF, olen); + *ie = malloc(len, M_DEVBUF, M_NOWAIT); if (*ie == NULL) return ENOMEM; } - memcpy(*ie, frm, 2 + frm[1]); + memcpy(*ie, frm, len); return 0; } |