From d985d2b50a41eb5f9ba682f4afe72ac2c59b53e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 21 Jun 2017 11:29:38 +0300 Subject: main/musl: cherry-pick upstream fixes --- ...handle-errors-from-localtime_r-in-ctime_r.patch | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 main/musl/0048-handle-errors-from-localtime_r-in-ctime_r.patch (limited to 'main/musl/0048-handle-errors-from-localtime_r-in-ctime_r.patch') diff --git a/main/musl/0048-handle-errors-from-localtime_r-in-ctime_r.patch b/main/musl/0048-handle-errors-from-localtime_r-in-ctime_r.patch new file mode 100644 index 0000000000..37d608e4a3 --- /dev/null +++ b/main/musl/0048-handle-errors-from-localtime_r-in-ctime_r.patch @@ -0,0 +1,31 @@ +From 64f855874c32e192382df69f4765a7e32057a005 Mon Sep 17 00:00:00 2001 +From: Rich Felker +Date: Tue, 20 Jun 2017 20:31:35 -0400 +Subject: [PATCH] handle errors from localtime_r in ctime_r + +POSIX requires ctime_r return a null pointer on failure, which can +occur if the input time_t value is not representable in broken down +form. + +based on patch by Alexander Monakov. +--- + src/time/ctime_r.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/src/time/ctime_r.c b/src/time/ctime_r.c +index d2260a16..3e24aa68 100644 +--- a/src/time/ctime_r.c ++++ b/src/time/ctime_r.c +@@ -2,7 +2,6 @@ + + char *ctime_r(const time_t *t, char *buf) + { +- struct tm tm; +- localtime_r(t, &tm); +- return asctime_r(&tm, buf); ++ struct tm tm, *tm_p = localtime_r(t, &tm); ++ return tm_p ? asctime_r(tm_p, buf) : 0; + } +-- +2.13.0 + -- cgit v1.2.3