]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tools: fix my_htonll() on x86_64
authorWilly Tarreau <w@1wt.eu>
Wed, 18 Oct 2017 09:39:33 +0000 (11:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 18 Oct 2017 09:46:17 +0000 (11:46 +0200)
Commit 36eb3a3 ("MINOR: tools: make my_htonll() more efficient on x86_64")
brought an incorrect asm statement missing the input constraints, causing
the input value not necessarily to be placed into the same register as the
output one, resulting in random output. It happens to work when building at
-O0 but not above. This was only detected in the HTTP/2 parser, but in
mainline it could only affect the integer to binary sample cast.

No backport is needed since this bug was only introduced in the development
branch.

include/common/standard.h

index 2645c44dd582efb013258537283fa7cbbffd66e9..535efa736303e6a619645320380a1b4b90a25f7d 100644 (file)
@@ -1202,7 +1202,7 @@ static inline unsigned char utf8_return_length(unsigned char code)
 static inline unsigned long long my_htonll(unsigned long long a)
 {
 #if defined(__x86_64__)
-       __asm__ volatile("bswap %0" : "=r"(a));
+       __asm__ volatile("bswap %0" : "=r"(a) : "0"(a));
        return a;
 #else
        union {