MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / getSafeInfoString

Function getSafeInfoString

src/server.cpp:5584–5593  ·  view source on GitHub ↗

Returns a sanitized version of s that contains no unsafe info string chars. * If no unsafe characters are found, simply returns s. Caller needs to * free tmp if it is non-null on return. */

Source from the content-addressed store, hash-verified

5582 * free tmp if it is non-null on return.
5583 */
5584const char *getSafeInfoString(const char *s, size_t len, char **tmp) {
5585 *tmp = NULL;
5586 if (mempbrk(s, len, unsafe_info_chars,sizeof(unsafe_info_chars)-1)
5587 == NULL) return s;
5588 char *_new = *tmp = (char*)zmalloc(len + 1);
5589 memcpy(_new, s, len);
5590 _new[len] = '\0';
5591 return memmapchars(_new, len, unsafe_info_chars, unsafe_info_chars_substs,
5592 sizeof(unsafe_info_chars)-1);
5593}
5594
5595/* Create the string returned by the INFO command. This is decoupled
5596 * by the INFO command itself as we need to report the same information

Callers 2

genRedisInfoStringFunction · 0.85
RM_InfoBeginDictFieldFunction · 0.85

Calls 3

mempbrkFunction · 0.85
zmallocFunction · 0.85
memmapcharsFunction · 0.85

Tested by

no test coverage detected