]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: fix listening IP address storage for frontends
authorVincent Bernat <vincent@bernat.im>
Wed, 18 May 2016 14:17:44 +0000 (16:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 May 2016 08:43:24 +0000 (10:43 +0200)
commit6e61589573f49b20a7184c9d297af1fc7d9184d8
treed2455d85ac11372904366a944e58dc992fcfb2f4
parent29c44e1f1e505071df35335b144e2d8bef7219c9
BUG/MAJOR: fix listening IP address storage for frontends

When compiled with GCC 6, the IP address specified for a frontend was
ignored and HAProxy was listening on all addresses instead. This is
caused by an incomplete copy of a "struct sockaddr_storage".

With the GNU Libc, "struct sockaddr_storage" is defined as this:

    struct sockaddr_storage
      {
        sa_family_t ss_family;
        unsigned long int __ss_align;
        char __ss_padding[(128 - (2 * sizeof (unsigned long int)))];
      };

Doing an aggregate copy (ss1 = ss2) is different than using memcpy():
only members of the aggregate have to be copied. Notably, padding can be
or not be copied. In GCC 6, some optimizations use this fact and if a
"struct sockaddr_storage" contains a "struct sockaddr_in", the port and
the address are part of the padding (between sa_family and __ss_align)
and can be not copied over.

Therefore, we replace any aggregate copy by a memcpy(). There is another
place using the same pattern. We also fix a function receiving a "struct
sockaddr_storage" by copy instead of by reference. Since it only needs a
read-only copy, the function is converted to request a reference.
include/proto/proto_http.h
src/cfgparse.c
src/connection.c
src/hlua.c
src/proto_http.c
src/proto_tcp.c