[PATCH] linux: fix ntp_gettime abi break
Kacper Piwiński
vfjpl1@gmail.com
Tue Feb 21 04:04:15 GMT 2023
Between versions v2.11 and v2.12 struct ntptimeval got new fields.
That wasn't a problem because new function ntp_gettimex was created
(and made default) to support new struct. Old ntp_gettime was not
using new fields so it was safe to call with old struct
definition. Then between versions v2.31 and v2.32 when working on
y2038 bugs, ntp_gettime start setting new fields.
Sets fields manually to maintain compatibility with v2.11 struct definition.
Author: Kacper Piwiński <vfjpl1@gmail.com>
---
sysdeps/unix/sysv/linux/ntp_gettime.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c
b/sysdeps/unix/sysv/linux/ntp_gettime.c
index 4879573530..3844b2e487 100644
--- a/sysdeps/unix/sysv/linux/ntp_gettime.c
+++ b/sysdeps/unix/sysv/linux/ntp_gettime.c
@@ -54,7 +54,11 @@ __ntp_gettime (struct ntptimeval *ntv)
int result;
result = __ntp_gettime64 (&ntv64);
- *ntv = valid_ntptimeval64_to_ntptimeval (ntv64);
+ //manually update fields to maintain abi with v2.11 struct definition
+ struct ntptimeval tntv = valid_ntptimeval64_to_ntptimeval (ntv64);
+ ntv->time = tntv.time;
+ ntv->maxerror = tntv.maxerror;
+ ntv->esterror = tntv.esterror;
return result;
}
--
2.38.1.windows.1
More information about the Libc-alpha
mailing list