]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: be more flexible with iso8601 timestamps 6162/head
authorAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Mon, 24 Aug 2015 17:41:35 +0000 (23:11 +0530)
committerLoic Dachary <ldachary@redhat.com>
Fri, 2 Oct 2015 14:49:44 +0000 (16:49 +0200)
make parsing 8601 more flexible by not restricting the length of seconds
to 5, this allows timestamp to be specified both as ms or us. Newer
keystone backends such as fernet token backend default to microseconds
when publishing iso8601 timestamps, so this allows these timestamps to
be allowed when specifying the token expiry time.

Fixes: #12761
Reported-by: Ian Unruh <ianunruh@gmail.com>
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@ril.com>
(cherry picked from commit 136242b5612b8bbf260910b1678389361e86d22a)

src/rgw/rgw_common.cc

index c270c6fdb0855a1008ca60fca58e1e944f14e7bc..d728cb4aee327a1b5329c75a0a3b5a54e7a1dc76 100644 (file)
@@ -341,18 +341,17 @@ bool parse_iso8601(const char *s, struct tm *t)
   }
   string str;
   trim_whitespace(p, str);
-  if (str.size() == 1 && str[0] == 'Z')
+  int len = str.size();
+
+  if (len == 1 && str[0] == 'Z')
     return true;
 
-  if (str.size() != 5) {
-    return false;
-  }
   if (str[0] != '.' ||
-      str[str.size() - 1] != 'Z')
+      str[len - 1] != 'Z')
     return false;
 
   uint32_t ms;
-  int r = stringtoul(str.substr(1, 3), &ms);
+  int r = stringtoul(str.substr(1, len - 2), &ms);
   if (r < 0)
     return false;