]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: send_proxy: fix initialisation of send_proxy_ofs
authorWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 13:20:43 +0000 (15:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 19:28:16 +0000 (21:28 +0200)
Commit b22e55bc introduced send_proxy_ofs but forgot to initialize it,
which remained unnoticed since it's always at the same place in the
stream interface. On a machine with dirty RAM returned by malloc(),
some responses were holding a PROXY header, which normally is not
possible.

The problem goes away after properly initializing the field upon each
new session_accept().

This fix does not need to be backported except if any code makes use of
a backport of this feature.

src/peers.c
src/session.c

index ba57e1868fc706fcfad55dcdd38758d75d9c1641..182d71d23e2ef2d8e5b620b99e4da72afb8d8fe7 100644 (file)
@@ -1156,6 +1156,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].err_loc = NULL;
        s->si[0].proto   = NULL;
        s->si[0].release = NULL;
+       s->si[0].send_proxy_ofs = 0;
        clear_target(&s->si[0].target);
        s->si[0].exp = TICK_ETERNITY;
        s->si[0].flags = SI_FL_NONE;
@@ -1174,6 +1175,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[1].err_loc = NULL;
        s->si[1].proto = peer->proto;
        s->si[1].release = NULL;
+       s->si[1].send_proxy_ofs = 0;
        set_target_proxy(&s->si[1].target, s->be);
        s->si[1].exp = TICK_ETERNITY;
        s->si[1].flags = SI_FL_NONE;
index af3a4644208cf0b4ca8274ec238f722629aa5ca8..862af58530cf24e7d7f8bee936cfc1c66b38a0ec 100644 (file)
@@ -171,6 +171,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->si[0].err_loc   = NULL;
        s->si[0].proto     = l->proto;
        s->si[0].release   = NULL;
+       s->si[0].send_proxy_ofs = 0;
        clear_target(&s->si[0].target);
        s->si[0].exp       = TICK_ETERNITY;
        s->si[0].flags     = SI_FL_NONE;
@@ -195,6 +196,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->si[1].err_loc   = NULL;
        s->si[1].proto     = NULL;
        s->si[1].release   = NULL;
+       s->si[1].send_proxy_ofs = 0;
        clear_target(&s->si[1].target);
        s->si[1].sock.shutr= stream_int_shutr;
        s->si[1].sock.shutw= stream_int_shutw;