]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: extend the CLI context with a list and two offsets
authorWilly Tarreau <w@1wt.eu>
Fri, 30 Aug 2019 06:05:03 +0000 (08:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 30 Aug 2019 09:58:58 +0000 (11:58 +0200)
Some CLI parsers are currently abusing the CLI context types such as
pointers to stuff longs into them by lack of room. But the context is
80 bytes while cli is only 48, thus there's some room left. This patch
adds a list element and two size_t usable as various offsets. The list
element is initialized.

include/types/applet.h
src/cli.c

index 1f3a4983a62911297fd58b1bc2481ec121f1988d..8de446cd149a3d6c7e8d497962c3f76dd7b62fee 100644 (file)
@@ -105,8 +105,10 @@ struct appctx {
                        const char *msg;        /* pointer to a persistent message to be returned in CLI_ST_PRINT state */
                        int severity;           /* severity of the message to be returned according to (syslog) rfc5424 */
                        char *err;              /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_FREE state */
-                       void *p0, *p1;          /* general purpose pointers and integers for registered commands, initialized */
-                       int i0, i1;             /* to 0 by the CLI before first invocation of the keyword parser. */
+                       struct list l0;         /* General purpose list element, pointers, offsets and integers for... */
+                       void *p0, *p1;          /* ...registered commands, initialized to 0 by the CLI before first... */
+                       size_t o0, o1;          /* ...invocation of the keyword parser, except for the list element which... */
+                       int i0, i1;             /* ...is initialized with LIST_INIT(). */
                } cli;                          /* context used by the CLI */
                struct {
                        struct cache_entry *entry;  /* Entry to be sent from cache. */
index 1805671492fdba625bf2fc18f400f69b00b2517d..ddc7f4c73742c4018954c67f32812598555a5908 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -498,6 +498,7 @@ static int cli_parse_request(struct appctx *appctx)
 
        appctx->st2 = 0;
        memset(&appctx->ctx.cli, 0, sizeof(appctx->ctx.cli));
+       LIST_INIT(&appctx->ctx.cli.l0);
 
        p = appctx->chunk->area;
        end = p + appctx->chunk->data;