diff --git a/src/cli.c b/src/cli.c index a64c2f448..5791a89ce 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2906,7 +2906,8 @@ int pcli_find_and_exec_kw(struct stream *s, char **args, int argl, char **errmsg * for the '@@' prefix. If found, the pid is returned in and the * function returns a positive value representing the number of bytes * processed. If the prefix is found but the pid couldn't be parsed, <0 is - * returned with an error placed into . If nothing is found, zero is + * returned with an error placed into . If the string is incomplete + * (missing '\n'), -1 is returned with no error. If nothing is found, zero is * returned. In any case, is advanced by the number of chars to be * skipped. */ @@ -2919,6 +2920,12 @@ int pcli_find_bidir_prefix(struct stream *s, struct channel *req, char **str, co while (p < end && (*p == '\t' || *p == ' ')) p++; + /* We only parse complete lines */ + if (memchr(p, '\n', end - p) == NULL) { + ret = -1; + goto leave; + } + /* check for '@@' prefix */ if (p + 2 <= end && p[0] == '@' && p[1] == '@') { const char *pid_str = p;