From: David Carlier <[email protected]>

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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/addons/deviceatlas/da.c b/addons/deviceatlas/da.c
index 3532c5541..24b513592 100644
--- a/addons/deviceatlas/da.c
+++ b/addons/deviceatlas/da.c
@@ -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 {
-- 
2.51.0



Reply via email to