mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
util: rework timestamp fuzzing
Use UTI_GetRandomBytes() instead of random() to generate random bits below precision. Save the result in NTP_int64 in the network order and allow precision in the full range from -32 to 32. With precision 32 the fuzzing now makes the timestamp completely random and can be used to hide the time.
This commit is contained in:
6
util.h
6
util.h
@@ -96,13 +96,13 @@ extern char *UTI_TimeToLogForm(time_t t);
|
||||
/* Adjust time following a frequency/offset change */
|
||||
extern void UTI_AdjustTimeval(struct timeval *old_tv, struct timeval *when, struct timeval *new_tv, double *delta, double dfreq, double doffset);
|
||||
|
||||
/* Get a random value to fuzz an NTP timestamp in the given precision */
|
||||
extern uint32_t UTI_GetNTPTsFuzz(int precision);
|
||||
/* Get zero NTP timestamp with random bits below precision */
|
||||
extern void UTI_GetInt64Fuzz(NTP_int64 *ts, int precision);
|
||||
|
||||
extern double UTI_Int32ToDouble(NTP_int32 x);
|
||||
extern NTP_int32 UTI_DoubleToInt32(double x);
|
||||
|
||||
extern void UTI_TimevalToInt64(struct timeval *src, NTP_int64 *dest, uint32_t fuzz);
|
||||
extern void UTI_TimevalToInt64(struct timeval *src, NTP_int64 *dest, NTP_int64 *fuzz);
|
||||
|
||||
extern void UTI_Int64ToTimeval(NTP_int64 *src, struct timeval *dest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user