diff options
author | dormando <dormando@rydia.net> | 2020-11-12 16:35:13 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2021-06-07 22:06:55 -0700 |
commit | d0b560d91a3bf7b7cda93759c48b5319e9743911 (patch) | |
tree | 97ba7fa11a1135ebd4303846532a66639a530057 | |
parent | f4aee656741421a41bc5e128f10e15be703c8927 (diff) | |
download | memcached-d0b560d91a3bf7b7cda93759c48b5319e9743911.tar.gz |
meta: protect cachedump from bin keys and add docs
cachedump was the only place in the codebase I can find which copied
the key verbatim. wonder when I can finally remove the command :)
-rw-r--r-- | doc/protocol.txt | 17 | ||||
-rw-r--r-- | items.c | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/doc/protocol.txt b/doc/protocol.txt index 2788253..49c12d8 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -456,9 +456,11 @@ Meta Debug The meta debug command is a human readable dump of all available internal metadata of an item, minus the value. -me <key>\r\n +me <key> <flag>\r\n - <key> means one key string. +- if <flag> is 'b', then <key> is a base64 encoded binary value. the response + key will also be base64 encoded. The response looks like: @@ -528,6 +530,7 @@ Unless the (q) flag was supplied, which suppresses the status code for a miss. The flags used by the 'mg' command are: +- b: interpret key as base64 encoded binary value - c: return item cas token - f: return client flags token - h: return whether item has been hit before as a 0 or 1 @@ -552,6 +555,15 @@ These extra flags can be added to the response: The flags are now repeated with detailed information where useful: +- b: interpret key as base64 encoded binary value + +This flag instructs memcached to run a base64 decoder on <key> before looking +it up. This allows storing and fetching of binary packed keys, so long as they +are sent to memcached in base64 encoding. + +If 'b' flag is sent in the response, and a key is returned via 'k', this +signals to the client that the key is base64 encoded binary. + - h: return whether item has been hit before as a 0 or 1 - l: return time since item was last accessed in seconds @@ -694,6 +706,7 @@ with CAS semantics did not exist. The flags used by the 'ms' command are: +- b: interpret key as base64 encoded binary value (see metaget) - C(token): compare CAS value when storing item - F(token): set client flags to token (32 bit unsigned numeric) - I: invalidate. set-to-invalid if supplied CAS is older than item's CAS @@ -774,6 +787,7 @@ Where CD is one of: The flags used by the 'md' command are: +- b: interpret key as base64 encoded binary value (see metaget) - C(token): compare CAS value - I: invalidate. mark as stale, bumps CAS. - k: return key @@ -846,6 +860,7 @@ VA <size> <flags>*\r\n The flags used by the 'ma' command are: +- b: interpret key as base64 encoded binary value (see metaget) - C(token): compare CAS value (see mset) - N(token): auto create item on miss with supplied TTL - J(token): initial value to use if auto created after miss (default 0) @@ -614,7 +614,8 @@ char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, u while (it != NULL && (limit == 0 || shown < limit)) { assert(it->nkey <= KEY_MAX_LENGTH); - if (it->nbytes == 0 && it->nkey == 0) { + // protect from printing binary keys. + if ((it->nbytes == 0 && it->nkey == 0) || (it->it_flags & ITEM_KEY_BINARY)) { it = it->next; continue; } |