From dea7c5c03de727f492e6ce2418a7651b4f0f6144 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 18 Oct 2017 11:39:33 +0200 Subject: [PATCH] BUG/MINOR: tools: fix my_htonll() on x86_64 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/common/standard.h b/include/common/standard.h index 2645c44dd..535efa736 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -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 {