public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Linux: Fix UTC offset setting in settimeofday for __TIMESIZE != 64
@ 2020-06-30 19:20 Florian Weimer
0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2020-06-30 19:20 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5f40e4b1ba69a22923f6ec692d2d0f65733ccb0b
commit 5f40e4b1ba69a22923f6ec692d2d0f65733ccb0b
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Jun 30 21:19:43 2020 +0200
Linux: Fix UTC offset setting in settimeofday for __TIMESIZE != 64
The time argument is NULL in this case, and attempt to convert it
leads to a null pointer dereference.
This fixes commit d2e3b697da2433c08702f95c76458c51545c3df1
("y2038: linux: Provide __settimeofday64 implementation").
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diff:
---
sysdeps/unix/sysv/linux/settimeofday.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/settimeofday.c b/sysdeps/unix/sysv/linux/settimeofday.c
index ea45f1d7cb..2bb589f8e2 100644
--- a/sysdeps/unix/sysv/linux/settimeofday.c
+++ b/sysdeps/unix/sysv/linux/settimeofday.c
@@ -25,6 +25,7 @@
int
__settimeofday64 (const struct __timeval64 *tv, const struct timezone *tz)
{
+ /* Backwards compatibility for setting the UTC offset. */
if (__glibc_unlikely (tz != 0))
{
if (tv != 0)
@@ -45,9 +46,13 @@ libc_hidden_def (__settimeofday64)
int
__settimeofday (const struct timeval *tv, const struct timezone *tz)
{
- struct __timeval64 tv64 = valid_timeval_to_timeval64 (*tv);
-
- return __settimeofday64 (&tv64, tz);
+ if (__glibc_unlikely (tv == NULL))
+ return __settimeofday64 (NULL, tz);
+ else
+ {
+ struct __timeval64 tv64 = valid_timeval_to_timeval64 (*tv);
+ return __settimeofday64 (&tv64, tz);
+ }
}
#endif
weak_alias (__settimeofday, settimeofday);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-30 19:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 19:20 [glibc] Linux: Fix UTC offset setting in settimeofday for __TIMESIZE != 64 Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).