summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Derrick Lyndon Pallas2020-04-21 17:01:27 -0700
committerGravatar Derrick Lyndon Pallas2020-04-21 17:19:24 -0700
commitb1c9fda74be24a69443f45d4470cbe14f69fe860 (patch)
treedd7e3ea66cf057947325c533da1830009e95bac1
parentfbee194fd9cc25e7438e73896ba81020ef1dd266 (diff)
downloadlibplist-b1c9fda74be24a69443f45d4470cbe14f69fe860.tar.gz
libplist-b1c9fda74be24a69443f45d4470cbe14f69fe860.tar.bz2
time64/ctime64_r: localtime64_r can fail
In ctime64_r, the call to localtime64_r can fail. If we don't check for this and then call asctime64_r, the results are garbage. Signed-off-by: Derrick Lyndon Pallas <derrick@pallas.us>
-rw-r--r--src/time64.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/time64.c b/src/time64.c
index 8c08caf..2ed8562 100644
--- a/src/time64.c
+++ b/src/time64.c
@@ -806,7 +806,9 @@ char *asctime64_r( const struct TM* date, char *result ) {
char *ctime64_r( const Time64_T* time, char* result ) {
struct TM date;
- localtime64_r( time, &date );
+ if (!localtime64_r( time, &date ))
+ return NULL;
+
return asctime64_r( &date, result );
}