[Slirp] [Git][slirp/libslirp][master] TCPIPHDR_DELTA: Fix potential negative value

Samuel Thibault gitlab at gitlab.freedesktop.org
Tue Aug 18 08:56:16 UTC 2020



Samuel Thibault pushed to branch master at slirp / libslirp


Commits:
e9b2bc19 by Samuel Thibault at 2020-08-18T10:54:47+02:00
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 at ens-lyon.org>

- - - - -


1 changed file:

- src/tcpip.h


Changes:

=====================================
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))
 
 /*



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/e9b2bc19ae652a2907f247e621b2e4773bdd2aab

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/e9b2bc19ae652a2907f247e621b2e4773bdd2aab
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20200818/78db6796/attachment.htm>


More information about the Slirp mailing list