mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-05 04:56:10 +02:00
BUG/MINOR: mworker/cli: check ci_insert() return value in pcli_parse_request()
All ci_insert() calls in pcli_parse_request() were ignoring the return value, silently miscounting the bytes to forward if an insertion failed. Add a check on each call and return -1 on failure. In practice this has no impact: the channel receive machinery enforces a maxrewrite reserve, so there is always sufficient room in the buffer for these small prefixes by the time pcli_parse_request() is called. Must be backported in every maintained versions, the list of available commands might change.
This commit is contained in:
parent
946921c199
commit
166dfcbbee
35
src/cli.c
35
src/cli.c
@ -3429,27 +3429,42 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
||||
/* the mcli-debug-mode is only sent to the applet of the master */
|
||||
if ((pcli->flags & ACCESS_MCLI_DEBUG) && *next_pid <= 0) {
|
||||
const char *cmd = "mcli-debug-mode on -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
if (pcli->flags & ACCESS_EXPERIMENTAL) {
|
||||
const char *cmd = "experimental-mode on -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
if (pcli->flags & ACCESS_EXPERT) {
|
||||
const char *cmd = "expert-mode on -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
if (pcli->flags & ACCESS_MCLI_SEVERITY_STR) {
|
||||
const char *cmd = "set severity-output string -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
if (pcli->flags & ACCESS_MCLI_SEVERITY_NB) {
|
||||
const char *cmd = "set severity-output number -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
|
||||
@ -3457,11 +3472,17 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
||||
goto end;
|
||||
} else if (pcli_has_level(s, ACCESS_LVL_OPER)) {
|
||||
const char *cmd = "operator -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
} else if (pcli_has_level(s, ACCESS_LVL_USER)) {
|
||||
const char *cmd = "user -;";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
if (!ci_insert(req, 0, cmd, strlen(cmd))) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
ret += strlen(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user