From: Yehuda Sadeh Date: Tue, 21 Jul 2015 03:27:33 +0000 (-0700) Subject: rgw: avoid using slashes for generated secret keys X-Git-Tag: v0.94.4~48^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5716%2Fhead;p=ceph.git rgw: avoid using slashes for generated secret keys Just use plain alphanumeric characterset. Fixes: #7647 Signed-off-by: Yehuda Sadeh (cherry picked from commit 3f04a6126fdbfb93304f798da3775c0eec9b7d44) --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index f3988cffd34..c270c6fdb08 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -525,6 +525,26 @@ int gen_rand_alphanumeric_no_underscore(CephContext *cct, char *dest, int size) return 0; } +static const char alphanum_plain_table[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + +int gen_rand_alphanumeric_plain(CephContext *cct, char *dest, int size) /* size should be the required string size + 1 */ +{ + int ret = get_random_bytes(dest, size); + if (ret < 0) { + lderr(cct) << "cannot get random bytes: " << cpp_strerror(-ret) << dendl; + return ret; + } + + int i; + for (i=0; i