Skip to content

Commit

Permalink
slirp: don't zero the whole ti_i when m == NULL
Browse files Browse the repository at this point in the history
98c6305 ('slirp: Factorizing
tcpiphdr structure with an union') introduced a memset call to clear
possibly-undefined fields in ti. This however overwrites src/dst/pr which
are used below.

So let us clear only the unused fields.

This should fix some rare cases (some RST cases, keep alive probes)
where packets would be sent to 0.0.0.0.

Signed-off-by: Tao Wu <lepton@google.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
  • Loading branch information
Tao Wu authored and sthibaul committed Nov 9, 2017
1 parent b0fbe46 commit 990132c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion slirp/tcp_subr.c
Expand Up @@ -148,7 +148,16 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
m->m_data += IF_MAXLINKHDR;
*mtod(m, struct tcpiphdr *) = *ti;
ti = mtod(m, struct tcpiphdr *);
memset(&ti->ti, 0, sizeof(ti->ti));
switch (af) {
case AF_INET:
ti->ti.ti_i4.ih_x1 = 0;
break;
case AF_INET6:
ti->ti.ti_i6.ih_x1 = 0;
break;
default:
g_assert_not_reached();
}
flags = TH_ACK;
} else {
/*
Expand Down

0 comments on commit 990132c

Please sign in to comment.