We have a few cases in which one of the paramters passed to
ASN1_TIME_diff is null (i.e. the caller doesn't care about the psec
differnce and so passes NULL as that pointer parameter).
However, OPENSSL_gmtime_diff assumes both pointers are valid, and so
writes to them unilaterally resulting in a crash as observed here:
https://github.com/openssl/openssl/pull/29333#issuecomment-
3628103959
Check the pointers before writing to them.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29337)
daydiff = timediff / SECS_PER_DAY;
timediff %= SECS_PER_DAY;
- *out_secs = (int)timediff;
- *out_days = (int)daydiff;
+ if (out_secs != NULL)
+ *out_secs = (int)timediff;
+ if (out_days != NULL)
+ *out_days = (int)daydiff;
return 1;
}