BUG/MINOR: master/cli: only parse the '@@' prefix on complete lines
The new adhoc parser for the '@@' prefix forgot to require the presence of the LF character marking the end of the line. This is the reason why entering incomplete commands would display garbage, because the line was expected to have its LF character replaced with a zero. The problem is well illustrated by using socat in raw mode: socat /tmp/master.sock STDIO,raw,echo=0 then entering "@@1 show info" one character at a time would error just after the second "@". The command must take care to report an incomplete line and wait for more data in such a case.
This commit is contained in:
parent
931d932b3e
commit
7a79f54c98
@ -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 <next_pid> 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 <errmsg>. If nothing is found, zero is
|
||||
* returned with an error placed into <errmsg>. If the string is incomplete
|
||||
* (missing '\n'), -1 is returned with no error. If nothing is found, zero is
|
||||
* returned. In any case, <str> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user