]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: sample: use strtoll() instead of atoll()
authorWilly Tarreau <w@1wt.eu>
Fri, 14 May 2021 06:51:53 +0000 (08:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 May 2021 06:51:53 +0000 (08:51 +0200)
atoll() is not portable, but strtoll() is more common. We must pass NULL
to the end pointer however since the parser must consume digits and stop
at the first non-digit char. No backport is needed as this was introduced
in 2.4-dev17 with commit 51c8ad45c ("MINOR: sample: converter: Add json_query
converter").

src/sample.c

index 08c5283f5e64c73993ff58d0d51c0a609cc7a7ae..09c272c48b9c40bd139bdff110868ced3cc293ef 100644 (file)
@@ -3743,7 +3743,7 @@ static int sample_conv_json_query(const struct arg *args, struct sample *smp, vo
        switch (token_type) {
                case MJSON_TOK_NUMBER:
                        if (args[1].type == ARGT_SINT) {
-                               smp->data.u.sint = atoll(token);
+                               smp->data.u.sint = strtoll(token, NULL, 0);
 
                                if (smp->data.u.sint < JSON_INT_MIN || smp->data.u.sint > JSON_INT_MAX)
                                        return 0;