[vlc-commits] network: do not assume socklen_t is unsigned

Rémi Denis-Courmont git at videolan.org
Sun Apr 14 09:05:35 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 14 09:52:35 2019 +0300| [b3f95facb78a6feed17b165109f9136a19f2065d] | committer: Rémi Denis-Courmont

network: do not assume socklen_t is unsigned

This is not guaranteed.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3f95facb78a6feed17b165109f9136a19f2065d
---

 src/network/udp.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/network/udp.c b/src/network/udp.c
index 9a4b04de33..c1cbd89643 100644
--- a/src/network/udp.c
+++ b/src/network/udp.c
@@ -332,7 +332,7 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
 
             level = SOL_IPV6;
-            assert (grplen >= sizeof (struct sockaddr_in6));
+            assert(grplen >= (socklen_t)sizeof (struct sockaddr_in6));
             if (g6->sin6_scope_id != 0)
                 gsr.gsr_interface = g6->sin6_scope_id;
             break;
@@ -346,9 +346,9 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
             return -1;
     }
 
-    assert (grplen <= sizeof (gsr.gsr_group));
+    assert(grplen <= (socklen_t)sizeof (gsr.gsr_group));
     memcpy (&gsr.gsr_source, src, srclen);
-    assert (srclen <= sizeof (gsr.gsr_source));
+    assert(srclen <= (socklen_t)sizeof (gsr.gsr_source));
     memcpy (&gsr.gsr_group,  grp, grplen);
     if (setsockopt (fd, level, MCAST_JOIN_SOURCE_GROUP,
                     &gsr, sizeof (gsr)) == 0)
@@ -370,9 +370,9 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
             struct ip_mreq_source imr;
 
             memset (&imr, 0, sizeof (imr));
-            assert (grplen >= sizeof (struct sockaddr_in));
+            assert(grplen >= (socklen_t)sizeof (struct sockaddr_in));
             imr.imr_multiaddr = ((const struct sockaddr_in *)grp)->sin_addr;
-            assert (srclen >= sizeof (struct sockaddr_in));
+            assert(srclen >= (socklen_t)sizeof (struct sockaddr_in));
             imr.imr_sourceaddr = ((const struct sockaddr_in *)src)->sin_addr;
             if (setsockopt (fd, SOL_IP, IP_ADD_SOURCE_MEMBERSHIP,
                             &imr, sizeof (imr)) == 0)
@@ -413,7 +413,7 @@ static int net_Subscribe(vlc_object_t *obj, int fd,
             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
 
             level = SOL_IPV6;
-            assert (grplen >= sizeof (struct sockaddr_in6));
+            assert(grplen >= (socklen_t)sizeof (struct sockaddr_in6));
             if (g6->sin6_scope_id != 0)
                 gr.gr_interface = g6->sin6_scope_id;
             break;
@@ -427,7 +427,7 @@ static int net_Subscribe(vlc_object_t *obj, int fd,
             return -1;
     }
 
-    assert (grplen <= sizeof (gr.gr_group));
+    assert(grplen <= (socklen_t)sizeof (gr.gr_group));
     memcpy (&gr.gr_group, grp, grplen);
     if (setsockopt (fd, level, MCAST_JOIN_GROUP, &gr, sizeof (gr)) == 0)
         return 0;
@@ -442,7 +442,7 @@ static int net_Subscribe(vlc_object_t *obj, int fd,
             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
 
             memset (&ipv6mr, 0, sizeof (ipv6mr));
-            assert (grplen >= sizeof (struct sockaddr_in6));
+            assert(grplen >= (socklen_t)sizeof (struct sockaddr_in6));
             ipv6mr.ipv6mr_multiaddr = g6->sin6_addr;
             ipv6mr.ipv6mr_interface = g6->sin6_scope_id;
             if (!setsockopt (fd, SOL_IPV6, IPV6_JOIN_GROUP,
@@ -457,7 +457,7 @@ static int net_Subscribe(vlc_object_t *obj, int fd,
             struct ip_mreq imr;
 
             memset (&imr, 0, sizeof (imr));
-            assert (grplen >= sizeof (struct sockaddr_in));
+            assert(grplen >= (socklen_t)sizeof (struct sockaddr_in));
             imr.imr_multiaddr = ((const struct sockaddr_in *)grp)->sin_addr;
             if (setsockopt (fd, SOL_IP, IP_ADD_MEMBERSHIP,
                             &imr, sizeof (imr)) == 0)



More information about the vlc-commits mailing list