aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-05-28 06:21:56 -0500
committerRob Landley <rob@landley.net>2021-05-28 06:21:56 -0500
commit657cc63108993c8b5a8eb69ebba5a708022a786a (patch)
treec7434a28f7443b320b4efd6a9847cbba93fec9ad /lib
parent54788b5670b1914061763b60a91d0842983ab428 (diff)
downloadtoybox-657cc63108993c8b5a8eb69ebba5a708022a786a.tar.gz
xparsedate should ignore trailing + or - (does not change timezone)
Diffstat (limited to 'lib')
-rw-r--r--lib/xwrap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 7e5e1500..a58707cc 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -1042,7 +1042,7 @@ void xparsedate(char *str, time_t *t, unsigned *nano, int endian)
while (isspace(*p)) p++;
if (*p && strchr("Z+-", *p)) {
unsigned uu[3] = {0}, n = 0, nn = 0;
- char *tz, sign = *p++;
+ char *tz = 0, sign = *p++;
if (sign == 'Z') tz = "UTC0";
else if (0<sscanf(p, " %u%n : %u%n : %u%n", uu,&n,uu+1,&nn,uu+2,&nn)) {
@@ -1057,13 +1057,13 @@ void xparsedate(char *str, time_t *t, unsigned *nano, int endian)
sprintf(tz = libbuf, "UTC%c%02u:%02u:%02u", "+-"[sign=='+'],
uu[0], uu[1], uu[2]);
p += nn;
- } else continue;
+ }
if (!oldtz) {
oldtz = getenv("TZ");
if (oldtz) oldtz = xstrdup(oldtz);
}
- setenv("TZ", tz, 1);
+ if (tz) setenv("TZ", tz, 1);
}
while (isspace(*p)) p++;