Browse Source

* try to fix parsing of 'jail <name> regex add <regex>'

master
Alex 'AdUser' Z 8 years ago
parent
commit
05b1f8423d
  1. 13
      src/commands.c

13
src/commands.c

@ -169,8 +169,17 @@ f2b_cmd_parse(const char *src, char *buf, size_t buflen) {
if (tokenc == 4 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "stats") == 0) { if (tokenc == 4 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "stats") == 0) {
return CMD_JAIL_REGEX_STATS; return CMD_JAIL_REGEX_STATS;
} }
if (tokenc == 5 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "add") == 0) { if (tokenc >= 5 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "add") == 0) {
strlcat(buf, tokens[4], buflen); /* TODO: rewrite, this version is very error-prone */
char *regex = strstr(src, "add");
regex += strlen("add");
while (isblank(*regex))
regex++;
if (*regex == '\0') {
/* empty regex */
return CMD_NONE;
}
strlcat(buf, regex, buflen);
strlcat(buf, "\n", buflen); strlcat(buf, "\n", buflen);
return CMD_JAIL_REGEX_ADD; return CMD_JAIL_REGEX_ADD;
} }

Loading…
Cancel
Save