projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1c86c7f
)
handle localtime errors in ctime
author
Rich Felker
<dalias@aerifal.cx>
Thu, 15 Jun 2017 16:58:08 +0000
(12:58 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 15 Jun 2017 16:58:08 +0000
(12:58 -0400)
ctime passes the result from localtime directly to asctime. But in case
of error, localtime returns 0. This causes an error (NULL pointer
dereference) in asctime.
based on patch by Omer Anson.
src/time/ctime.c
patch
|
blob
|
history
diff --git
a/src/time/ctime.c
b/src/time/ctime.c
index 185ec5543b958e04ff7560ae333ed7cac61a9c2c..36029315128f250a86264447ee20a95bd7f366b7 100644
(file)
--- a/
src/time/ctime.c
+++ b/
src/time/ctime.c
@@
-2,5
+2,7
@@
char *ctime(const time_t *t)
{
- return asctime(localtime(t));
+ struct tm *tm = localtime(t);
+ if (!tm) return 0;
+ return asctime(tm);
}