From: Ronen Friedman Date: Tue, 6 Jul 2021 15:45:21 +0000 (+0000) Subject: common/hobject: fix the handling of non-printable chars when listing hobjects X-Git-Tag: v17.1.0~1433^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0b089f6b8725dc3687cde941b77b0df1cc5c2ef9;p=ceph.git common/hobject: fix the handling of non-printable chars when listing hobjects The 'char >= 127' test was always(*) false. (*) ostensibly - compiler dependent Signed-off-by: Ronen Friedman --- diff --git a/src/common/hobject.cc b/src/common/hobject.cc index 85d4237dcd58..fe4af49d8e9b 100644 --- a/src/common/hobject.cc +++ b/src/common/hobject.cc @@ -211,13 +211,14 @@ void hobject_t::generate_test_instances(list& o) static void append_out_escaped(const string &in, string *out) { for (string::const_iterator i = in.begin(); i != in.end(); ++i) { - if (*i == '%' || *i == ':' || *i == '/' || *i < 32 || *i >= 127) { + int k = (int)(unsigned char)(*i); + if (k == '%' || k == ':' || k == '/' || k < 32 || k >= 127) { out->push_back('%'); char buf[3]; - snprintf(buf, sizeof(buf), "%02x", (int)(unsigned char)*i); + snprintf(buf, sizeof(buf), "%02x", (int)(unsigned char)k); out->append(buf); } else { - out->push_back(*i); + out->push_back(k); } } }