mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-21 18:25:41 +03:00
53 lines
1.5 KiB
Diff
53 lines
1.5 KiB
Diff
Patch by Robin Mueller
|
|
|
|
libmusl doesn't support the z character in the format pattern for strptime this
|
|
is a special functionality of glibc.
|
|
|
|
patch is slightly adapted version of glibc code:
|
|
https://elixir.bootlin.com/glibc/latest/source/time/strptime_l.c#L776
|
|
|
|
--- a/src/rgw/rgw_common.cc 2021-07-08 16:03:56.000000000 +0200
|
|
+++ b/src/rgw/rgw_common.cc 2021-08-18 13:08:22.938903459 +0200
|
|
@@ -531,7 +531,41 @@
|
|
{
|
|
// FIPS zeroization audit 20191115: this memset is not security related.
|
|
memset(t, 0, sizeof(*t));
|
|
- return check_str_end(strptime(s, "%a, %d %b %Y %H:%M:%S %z", t));
|
|
+ s = strptime(s, "%a, %d %b %Y %H:%M:%S", t);
|
|
+ if (s) {
|
|
+ s++;
|
|
+ int val;
|
|
+ val = 0;
|
|
+ while (isspace(*s))
|
|
+ ++s;
|
|
+ if (*s == 'Z') {
|
|
+ ++s;
|
|
+ t->tm_gmtoff = 0;
|
|
+ } else {
|
|
+ if (*s != '+' && *s != '-')
|
|
+ return 0;
|
|
+ bool neg = *s++ == '-';
|
|
+ int n = 0;
|
|
+ while (n < 4 && *s >= '0' && *s <= '9') {
|
|
+ val = val * 10 + *s++ - '0';
|
|
+ ++n;
|
|
+ if (*s == ':' && n == 2 && isdigit (*(s + 1)))
|
|
+ ++s;
|
|
+ }
|
|
+ if (n == 2)
|
|
+ val *= 100;
|
|
+ else if (n != 4)
|
|
+ /* Only two or four digits recognized. */
|
|
+ return 0;
|
|
+ else if (val % 100 >= 60)
|
|
+ /* Minutes valid range is 0 through 59. */
|
|
+ return 0;
|
|
+ t->tm_gmtoff = (val / 100) * 3600 + (val % 100) * 60;
|
|
+ if (neg)
|
|
+ t->tm_gmtoff = -t->tm_gmtoff;
|
|
+ }
|
|
+ }
|
|
+ return check_str_end(s);
|
|
}
|
|
|
|
bool parse_rfc2616(const char *s, struct tm *t)
|