diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-23 09:26:33 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-23 09:26:33 -0700 |
commit | 8fc3087792399e1caef1be7b616fc65c6879090c (patch) | |
tree | 592a1d3a6da426686b81840200381fd0392d17d9 | |
parent | de5d1da810732ee48f41e8be18257053d862301b (diff) | |
download | ceph-8fc3087792399e1caef1be7b616fc65c6879090c.tar.gz |
rgw: fix hex string translationwip-4755
Fixes: #4755
Original issue was that we implicitly assumed that char
is signed, which is not the case on all architectures and
was breaking arm. This fix avoids the implicit signed declaration
and makes the actual test clearer.
Reported-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_common.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index d9c0a809ac7..8f6fa686978 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -559,14 +559,14 @@ bool verify_object_permission(struct req_state *s, int perm) return verify_object_permission(s, s->bucket_acl, s->object_acl, perm); } -static char hex_to_num(char c) +static char hex_to_nibble(char c) { static char table[256]; static bool initialized = false; if (!initialized) { - memset(table, -1, sizeof(table)); + memset(table, 0x10, sizeof(table)); int i; for (i = '0'; i<='9'; i++) table[i] = i - '0'; @@ -597,14 +597,14 @@ bool url_decode(string& src_str, string& dest_str) src++; if (!*src) break; - char c1 = hex_to_num(*src++); + char c1 = hex_to_nibble(*src++); if (!*src) break; - c = c1 << 4; - if (c1 < 0) + if (c1 >= 0x10) return false; - c1 = hex_to_num(*src++); - if (c1 < 0) + c = c1 << 4; + c1 = hex_to_nibble(*src++); + if (c1 >= 0x10) return false; c |= c1; dest[pos++] = c; |