BUG/MINOR: http: base32+src should use the big endian version of base32
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2014 19:34:06 +0000 (21:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2014 19:36:10 +0000 (21:36 +0200)
We're using the internal memory representation of base32 here, which is
wrong since these data might be exported to headers for logs or be used
to stick to a server and replicated to other peers. Let's convert base32
to big endian (network representation) when building the binary block.

This mistake is also present in 1.5, it would be better to backport it.

src/proto_http.c

index 2017494..9e50796 100644 (file)
@@ -10358,8 +10358,8 @@ smp_fetch_base32_src(struct proxy *px, struct session *l4, void *l7, unsigned in
                return 0;
 
        temp = get_trash_chunk();
-       memcpy(temp->str + temp->len, &smp->data.uint, sizeof(smp->data.uint));
-       temp->len += sizeof(smp->data.uint);
+       *(unsigned int *)temp->str = htonl(smp->data.uint);
+       temp->len += sizeof(unsigned int);
 
        switch (cli_conn->addr.from.ss_family) {
        case AF_INET: