about summary refs log tree commit diff
path: root/compat
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-12-08 10:35:04 -0500
committerRich Felker <dalias@aerifal.cx>2019-12-08 10:35:04 -0500
commit9432bbd4e880850357fd0a81b429499451eb2084 (patch)
tree180513b03ef7ff013ad98617b2181f7e7d90c524 /compat
parentb1e2aae0aa6edd91413b288b9cc6939f2d80e302 (diff)
downloadmusl-9432bbd4e880850357fd0a81b429499451eb2084.tar.gz
musl-9432bbd4e880850357fd0a81b429499451eb2084.tar.xz
musl-9432bbd4e880850357fd0a81b429499451eb2084.zip
fix null pointer dereference in setitimer time32 compat shim
this interface permits a null pointer for where to store the old
itimerval being replaced. an early version of the time32 compat shim
code had corresponding bugs for lots of functions; apparently
setitimer was overlooked when fixing them.
Diffstat (limited to 'compat')
-rw-r--r--compat/time32/setitimer_time32.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/compat/time32/setitimer_time32.c b/compat/time32/setitimer_time32.c
index 4651dacb..2475fd8c 100644
--- a/compat/time32/setitimer_time32.c
+++ b/compat/time32/setitimer_time32.c
@@ -15,9 +15,11 @@ int __setitimer_time32(int which, const struct itimerval32 *restrict new32, stru
 	 * timer setting, so we can't fail on out-of-range old value.
 	 * Since these are relative times, values large enough to overflow
 	 * don't make sense anyway. */
-	old32->it_interval.tv_sec = old.it_interval.tv_sec;
-	old32->it_interval.tv_usec = old.it_interval.tv_usec;
-	old32->it_value.tv_sec = old.it_value.tv_sec;
-	old32->it_value.tv_usec = old.it_value.tv_usec;
+	if (old32) {
+		old32->it_interval.tv_sec = old.it_interval.tv_sec;
+		old32->it_interval.tv_usec = old.it_interval.tv_usec;
+		old32->it_value.tv_sec = old.it_value.tv_sec;
+		old32->it_value.tv_usec = old.it_value.tv_usec;
+	}
 	return 0;
 }