Fresh pull from upstream
[librecmc/librecmc.git] / toolchain / musl / patches / 053-fix-gratuitous-undefined-behavior-in-strptime.patch
1 From f33b17585058381491e6fda08f491b8e48c7980c Mon Sep 17 00:00:00 2001
2 From: Rich Felker <dalias@aerifal.cx>
3 Date: Thu, 20 Oct 2016 13:22:20 -0400
4 Subject: fix gratuitous undefined behavior in strptime
5
6 accessing an object of type const char *restrict as if it had type
7 char * is not defined.
8 ---
9  src/time/strptime.c | 9 +++++++--
10  1 file changed, 7 insertions(+), 2 deletions(-)
11
12 diff --git a/src/time/strptime.c b/src/time/strptime.c
13 index f41f55f..55c7ed1 100644
14 --- a/src/time/strptime.c
15 +++ b/src/time/strptime.c
16 @@ -22,8 +22,13 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
17                 }
18                 f++;
19                 if (*f == '+') f++;
20 -               if (isdigit(*f)) w=strtoul(f, (void *)&f, 10);
21 -               else w=-1;
22 +               if (isdigit(*f)) {
23 +                       char *new_f;
24 +                       w=strtoul(f, &new_f, 10);
25 +                       f = new_f;
26 +               } else {
27 +                       w=-1;
28 +               }
29                 adj=0;
30                 switch (*f++) {
31                 case 'a': case 'A':
32 -- 
33 cgit v0.11.2