]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: deviceatlas: fix cookie vlen using wrong length after extraction
authorDavid Carlier <dcarlier@deviceatlas.com>
Sat, 14 Feb 2026 13:23:59 +0000 (13:23 +0000)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Feb 2026 13:47:22 +0000 (14:47 +0100)
In da_haproxy_fetch(), vlen was set from v.len (the raw header value
length) instead of the truncated copy length. Also the cookie-specific
vlen calculation used an incorrect subtraction instead of the actual
extracted cookie value length (pl) returned by
http_extract_cookie_value().

This should be backported to lower branches.

addons/deviceatlas/da.c

index 3532c55415286e2a520097913eeb67fc693ac5cd..24b5135922494aa132151a9655078ed659a3f24a 100644 (file)
@@ -464,13 +464,12 @@ static int da_haproxy_fetch(const struct arg *args, struct sample *smp, const ch
 
                memcpy(hbuf, n.ptr, n.len);
                hbuf[n.len] = 0;
-               pval = v.ptr;
-               vlen = v.len;
                evid = -1;
                i = v.len > sizeof(tval) - 1 ? sizeof(tval) - 1 : v.len;
                memcpy(tval, v.ptr, i);
                tval[i] = 0;
                pval = tval;
+               vlen = i;
 
                if (strcasecmp(hbuf, "Accept-Language") == 0) {
                        evid = da_atlas_accept_language_evidence_id(&global_deviceatlas.atlas);
@@ -488,7 +487,7 @@ static int da_haproxy_fetch(const struct arg *args, struct sample *smp, const ch
                                continue;
                        }
 
-                       vlen -= global_deviceatlas.cookienamelen - 1;
+                       vlen = pl;
                        pval = p;
                        evid = da_atlas_clientprop_evidence_id(&global_deviceatlas.atlas);
                } else {