]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: sample: Don't treat SMP_T_METH as SMP_T_STR.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 7 Dec 2018 14:23:41 +0000 (15:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Dec 2018 14:31:43 +0000 (15:31 +0100)
In smp_dup(), don't consider a SMP_T_METH with an unknown method the same as
SMP_T_STR. The string and string length aren't stored at the same place.

This should be backported to 1.8.

src/sample.c

index 134ff76f5f9ffddccb373617b43935045f0041da..88217501d4c7e24f97aacac9bece53de050a0114 100644 (file)
@@ -666,11 +666,14 @@ int smp_dup(struct sample *smp)
 
        case SMP_T_STR:
                trash = get_trash_chunk();
-               trash->data = smp->data.u.str.data;
+               trash->data = smp->data.type == SMP_T_STR ?
+                   smp->data.u.str.data : smp->data.u.meth.str.data;
                if (trash->data > trash->size - 1)
                        trash->data = trash->size - 1;
 
-               memcpy(trash->area, smp->data.u.str.area, trash->data);
+               memcpy(trash->area, smp->data.type == SMP_T_STR ?
+                   smp->data.u.str.area : smp->data.u.meth.str.area,
+                   trash->data);
                trash->area[trash->data] = 0;
                smp->data.u.str = *trash;
                break;