]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: samples: Handle the type SMP_T_METH when we duplicate a sample in smp_dup
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 24 Jul 2017 13:38:41 +0000 (15:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 24 Jul 2017 15:15:47 +0000 (17:15 +0200)
First, the type SMP_T_METH was not handled by smp_dup function. It was never
called with this kind of samples, so it's not really a problem. But, this could
be useful in future.

For all known HTTP methods (GET, POST...), there is no extra space allocated for
a sample of type SMP_T_METH. But for unkown methods, it uses a chunk. So, like
for strings, we duplicate data, using a trash chunk.

src/sample.c

index 20a59bea9876945957515befa50d05a1063ce1b3..28a5fcb26286b7030e9780bffb3f027c2b2f30da 100644 (file)
@@ -658,6 +658,11 @@ int smp_dup(struct sample *smp)
                /* These type are not const. */
                break;
 
+       case SMP_T_METH:
+               if (smp->data.u.meth.meth != HTTP_METH_OTHER)
+                       break;
+               /* Fall through */
+
        case SMP_T_STR:
                trash = get_trash_chunk();
                trash->len = smp->data.u.str.len;
@@ -678,6 +683,7 @@ int smp_dup(struct sample *smp)
                memcpy(trash->str, smp->data.u.str.str, trash->len);
                smp->data.u.str = *trash;
                break;
+
        default:
                /* Other cases are unexpected. */
                return 0;