Skip to content

Commit

Permalink
INTERNAL: Check ntokens in the prefix related stats command
Browse files Browse the repository at this point in the history
  • Loading branch information
namsic committed Dec 11, 2024
1 parent 6a52829 commit f570cf2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -8209,8 +8209,11 @@ static void process_stats_command(conn *c, token_t *tokens, const size_t ntokens
/* NOTE: how to tackle detail with binary? */
if (ntokens < 4)
process_stats_detail(c, ""); /* outputs the error message */
else
else if (ntokens == 4) {
process_stats_detail(c, tokens[2].value);
} else {
out_string(c, "CLIENT_ERROR bad command line format");
}
/* Output already generated */
return;
} else if (strcmp(subcommand, "settings") == 0) {
Expand All @@ -8232,7 +8235,13 @@ static void process_stats_command(conn *c, token_t *tokens, const size_t ntokens
topkeys_stats(default_topkeys, c, get_current_time(), append_ascii_stats);
} else if (strcmp(subcommand, "prefixes") == 0) {
int len;
char *stats = mc_engine.v1->prefix_dump_stats(mc_engine.v0, c, NULL, 0, &len);
char *stats;

if (ntokens != 3) {
out_string(c, "CLIENT_ERROR bad command line format");
return;
}
stats = mc_engine.v1->prefix_dump_stats(mc_engine.v0, c, NULL, 0, &len);
if (stats == NULL) {
if (len == -1)
out_string(c, "NOT_SUPPORTED");
Expand Down

0 comments on commit f570cf2

Please sign in to comment.