fix null pointer dereference in setitimer time32 compat shim
authorRich Felker <dalias@aerifal.cx>
Sun, 8 Dec 2019 15:35:04 +0000 (10:35 -0500)
committerRich Felker <dalias@aerifal.cx>
Sun, 8 Dec 2019 15:35:04 +0000 (10:35 -0500)
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.

compat/time32/setitimer_time32.c

index 4651dacbdf181b936ecb3eedb7f11290b14a1f49..2475fd8c1110c78b21f15baf2e8a979e6861bc26 100644 (file)
@@ -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;
 }