eapol: Don't memcpy if no extra data

As reported by the sanitizer:

src/eapol.c:574:2: runtime error: null pointer passed as argument 2,
	which is declared to never be null
This commit is contained in:
Denis Kenzior 2019-01-11 17:10:47 -06:00
parent 30cf1aa376
commit e256cbaba9
1 changed files with 3 additions and 1 deletions

View File

@ -570,8 +570,10 @@ static struct eapol_key *eapol_create_common(
out_frame->key_length = 0;
out_frame->key_replay_counter = L_CPU_TO_BE64(key_replay_counter);
memcpy(out_frame->key_nonce, snonce, sizeof(out_frame->key_nonce));
out_frame->key_data_len = L_CPU_TO_BE16(extra_len);
memcpy(out_frame->key_data, extra_data, extra_len);
if (extra_len)
memcpy(out_frame->key_data, extra_data, extra_len);
return out_frame;
}