ntp: fix exp1 EF search in process_response()

Don't ignore the magic field when searching for the exp1 extension
field in a received response. If there were two exp1 fields in the
packet, and only one of them had the expected magic value, it should
pick the right one.

Fixes: 2319f72b29 ("ntp: add client support for experimental extension field")
This commit is contained in:
Miroslav Lichvar 2021-11-23 10:35:22 +01:00
parent dbbdd5af06
commit 09067e06d3

View file

@ -1721,7 +1721,9 @@ process_response(NCR_Instance inst, NTP_Local_Address *local_addr,
switch (ef_type) { switch (ef_type) {
case NTP_EF_EXP1: case NTP_EF_EXP1:
if (inst->ext_field_flags & NTP_EF_FLAG_EXP1 && ef_body_length == sizeof (*ef_exp1)) if (inst->ext_field_flags & NTP_EF_FLAG_EXP1 &&
ef_body_length == sizeof (*ef_exp1) &&
ntohl(((NTP_ExtFieldExp1 *)ef_body)->magic) == NTP_EF_EXP1_MAGIC)
ef_exp1 = ef_body; ef_exp1 = ef_body;
break; break;
} }