aboutsummaryrefslogtreecommitdiffstats
path: root/main/dovecot/fix-oauth2-jwt.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/dovecot/fix-oauth2-jwt.c.patch')
-rw-r--r--main/dovecot/fix-oauth2-jwt.c.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/main/dovecot/fix-oauth2-jwt.c.patch b/main/dovecot/fix-oauth2-jwt.c.patch
new file mode 100644
index 00000000000..b3755f6993e
--- /dev/null
+++ b/main/dovecot/fix-oauth2-jwt.c.patch
@@ -0,0 +1,55 @@
+From 42c37d2473116bf4a7fcafcaf94de83947fe80bc Mon Sep 17 00:00:00 2001
+From: Aki Tuomi <aki.tuomi@open-xchange.com>
+Date: Thu, 13 Aug 2020 20:01:41 +0300
+Subject: [PATCH] oauth2-jwt: Use int64_t instead time_t for portability
+
+
+diff --git a/src/lib-oauth2/oauth2-jwt.c b/src/lib-oauth2/oauth2-jwt.c
+index a68875e57..0adf612d9 100644
+--- a/src/lib-oauth2/oauth2-jwt.c
++++ b/src/lib-oauth2/oauth2-jwt.c
+@@ -31,18 +31,25 @@ static const char *get_field(const struct json_tree *tree, const char *key)
+ }
+
+ static int get_time_field(const struct json_tree *tree, const char *key,
+- long *value_r)
++ int64_t *value_r)
+ {
++ time_t tvalue;
+ const char *value = get_field(tree, key);
+ int tz_offset ATTR_UNUSED;
+ if (value == NULL)
+ return 0;
+- if ((str_to_long(value, value_r) < 0 &&
+- !iso8601_date_parse((const unsigned char*)value, strlen(value),
+- value_r, &tz_offset)) ||
+- *value_r < 0)
+- return -1;
+- return 1;
++ if (str_to_int64(value, value_r) == 0) {
++ if (*value_r < 0)
++ return -1;
++ return 1;
++ } else if (iso8601_date_parse((const unsigned char*)value, strlen(value),
++ &tvalue, &tz_offset)) {
++ if (tvalue < 0)
++ return -1;
++ *value_r = tvalue;
++ return 1;
++ }
++ return -1;
+ }
+
+ static int oauth2_lookup_hmac_key(const struct oauth2_settings *set,
+@@ -283,9 +290,9 @@ oauth2_jwt_body_process(const struct oauth2_settings *set, const char *alg, cons
+ const char *sub = get_field(tree, "sub");
+
+ int ret;
+- long t0 = time(NULL);
++ int64_t t0 = time(NULL);
+ /* default IAT and NBF to now */
+- long iat, nbf, exp;
++ int64_t iat, nbf, exp;
+ int tz_offset ATTR_UNUSED;
+
+ if (sub == NULL) {