mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 11:05:08 -05:00
test: fix ntp_core unit test
Fix setting of key_id in the response.
Fixes: f6625717cd ("test: improve ntp_core unit test")
This commit is contained in:
@@ -234,7 +234,9 @@ send_response(int interleaved, int authenticated, int allow_update, int valid_ts
|
|||||||
((unsigned char *)res)[res_length - auth_len + random() % auth_len]++;
|
((unsigned char *)res)[res_length - auth_len + random() % auth_len]++;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
res_length -= 4 + 4 * (random() % (auth_len / 4));
|
res_length -= 4 + auth_len;
|
||||||
|
auth_len = 4 * (random() % (auth_len / 4));
|
||||||
|
res_length += 4 + auth_len;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (NTP_LVM_TO_VERSION(res->lvm) == 4 && random() % 2 &&
|
if (NTP_LVM_TO_VERSION(res->lvm) == 4 && random() % 2 &&
|
||||||
@@ -248,6 +250,7 @@ send_response(int interleaved, int authenticated, int allow_update, int valid_ts
|
|||||||
res_length += 4 + auth_len;
|
res_length += 4 + auth_len;
|
||||||
} else {
|
} else {
|
||||||
memset((unsigned char *)res + res_length, 0, 4);
|
memset((unsigned char *)res + res_length, 0, 4);
|
||||||
|
auth_len += 4;
|
||||||
res_length += 4;
|
res_length += 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -256,6 +259,9 @@ send_response(int interleaved, int authenticated, int allow_update, int valid_ts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(res_length <= sizeof (*res));
|
||||||
|
assert(res_length >= NTP_HEADER_LENGTH + auth_len);
|
||||||
|
|
||||||
if (authenticated)
|
if (authenticated)
|
||||||
*(uint32_t *)((unsigned char *)res + res_length - auth_len - 4) = htonl(key_id);
|
*(uint32_t *)((unsigned char *)res + res_length - auth_len - 4) = htonl(key_id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user