mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
BUG/MEDIUM: cli: always reset the service context between commands
Erwan Le Goas reported that chaining certain commands on the CLI would systematically crash the process; for example, "show version; show sess". This happened since the conversion of cli context to appctx->svcctx, because if applet_reserve_svcctx() is called a first time for a tiny context, it's allocated in-situ, and later a keyword that wants a larger one will see that it's not null and will reuse it and will overwrite the end of the first one's context. What is missing is a reset of the svcctx when looping back to CLI_ST_GETREQ. This needs to be backported to 2.6, and relies on previous commit "MINOR: applet: add a function to reset the svcctx of an applet".
This commit is contained in:
parent
1cc08a33e1
commit
1addf8b777
@ -896,6 +896,7 @@ static void cli_io_handler(struct appctx *appctx)
|
|||||||
if (appctx->st0 == CLI_ST_INIT) {
|
if (appctx->st0 == CLI_ST_INIT) {
|
||||||
/* reset severity to default at init */
|
/* reset severity to default at init */
|
||||||
appctx->cli_severity_output = bind_conf->severity_output;
|
appctx->cli_severity_output = bind_conf->severity_output;
|
||||||
|
applet_reset_svcctx(appctx);
|
||||||
appctx->st0 = CLI_ST_GETREQ;
|
appctx->st0 = CLI_ST_GETREQ;
|
||||||
appctx->cli_level = bind_conf->level;
|
appctx->cli_level = bind_conf->level;
|
||||||
}
|
}
|
||||||
@ -1106,8 +1107,10 @@ static void cli_io_handler(struct appctx *appctx)
|
|||||||
prompt = "\n";
|
prompt = "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applet_putstr(appctx, prompt) != -1)
|
if (applet_putstr(appctx, prompt) != -1) {
|
||||||
|
applet_reset_svcctx(appctx);
|
||||||
appctx->st0 = CLI_ST_GETREQ;
|
appctx->st0 = CLI_ST_GETREQ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the output functions are still there, it means they require more room. */
|
/* If the output functions are still there, it means they require more room. */
|
||||||
@ -1128,6 +1131,7 @@ static void cli_io_handler(struct appctx *appctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* switch state back to GETREQ to read next requests */
|
/* switch state back to GETREQ to read next requests */
|
||||||
|
applet_reset_svcctx(appctx);
|
||||||
appctx->st0 = CLI_ST_GETREQ;
|
appctx->st0 = CLI_ST_GETREQ;
|
||||||
applet_will_consume(appctx);
|
applet_will_consume(appctx);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user