diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-08-18 10:51:20 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-08-18 10:54:47 +0200 |
commit | e9b2bc19ae652a2907f247e621b2e4773bdd2aab (patch) | |
tree | 91b8ae8f85eede69df6ac19582230bd1c8239531 | |
parent | a4e41a7e1d6a3a1aab972b36f8a6cdf570bb82b7 (diff) | |
download | slirp-e9b2bc19ae652a2907f247e621b2e4773bdd2aab.zip slirp-e9b2bc19ae652a2907f247e621b2e4773bdd2aab.tar.gz slirp-e9b2bc19ae652a2907f247e621b2e4773bdd2aab.tar.bz2 |
TCPIPHDR_DELTA: Fix potential negative value
sizeof() returns a size_t so the tcpiphdr / ip+tcphdr difference will be
a size_t and always be >= 0, while this intended to detect the
difference getting < 0.
This is actually a no-op with the current code because it currently has
tcpiphdr bigger than ip+tcphdr.
Spotted by Coverity: CID 212435.
Spotted by Coverity: CID 212440.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r-- | src/tcpip.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tcpip.h b/src/tcpip.h index d3df021..a0fb228 100644 --- a/src/tcpip.h +++ b/src/tcpip.h @@ -88,8 +88,8 @@ struct tcpiphdr { /* This is the difference between the size of a tcpiphdr structure, and the * size of actual ip+tcp headers, rounded up since we need to align data. */ #define TCPIPHDR_DELTA \ - (MAX(0, (sizeof(struct tcpiphdr) - sizeof(struct ip) - \ - sizeof(struct tcphdr) + 3) & \ + (MAX(0, ((int) sizeof(struct tcpiphdr) - (int) sizeof(struct ip) - \ + (int) sizeof(struct tcphdr) + 3) & \ ~3)) /* |