vlc | branch: master | Sergio Ammirata <ser...@ammirata.net> | Tue Nov 27 
08:15:28 2018 -0500| [732201ca09b0d99ab68ec9613542fa72e6db3c1d] | committer: 
Thomas Guillem

access: rist: check the return value of getsockopt

Signed-off-by: Thomas Guillem <tho...@gllm.fr>

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

 modules/access/rist.h | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/modules/access/rist.h b/modules/access/rist.h
index 256c1fcf63..574bc40cd9 100644
--- a/modules/access/rist.h
+++ b/modules/access/rist.h
@@ -278,15 +278,17 @@ static inline ssize_t rist_WriteTo_i11e(int fd, const 
void *buf, size_t len,
         && net_errno != ENOBUFS && net_errno != ENOMEM )
     {
         int type;
-        getsockopt( fd, SOL_SOCKET, SO_TYPE,
-                    &type, &(socklen_t){ sizeof(type) });
-        if( type == SOCK_DGRAM )
+        if (!getsockopt( fd, SOL_SOCKET, SO_TYPE,
+                    &type, &(socklen_t){ sizeof(type) }))
         {
-            /* ICMP soft error: ignore and retry */
-            if (slen == 0)
-                r = vlc_send_i11e( fd, buf, len, 0 );
-            else
-                r = vlc_sendto_i11e( fd, buf, len, 0, peer, slen );
+            if( type == SOCK_DGRAM )
+            {
+                /* ICMP soft error: ignore and retry */
+                if (slen == 0)
+                    r = vlc_send_i11e( fd, buf, len, 0 );
+                else
+                    r = vlc_sendto_i11e( fd, buf, len, 0, peer, slen );
+            }
         }
     }
     return r;
@@ -315,15 +317,17 @@ static inline ssize_t rist_WriteTo(int fd, const void 
*buf, size_t len, const st
         && net_errno != ENOBUFS && net_errno != ENOMEM )
     {
         int type;
-        getsockopt( fd, SOL_SOCKET, SO_TYPE,
-                    &type, &(socklen_t){ sizeof(type) });
-        if( type == SOCK_DGRAM )
+        if (!getsockopt( fd, SOL_SOCKET, SO_TYPE,
+                    &type, &(socklen_t){ sizeof(type) }))
         {
-            /* ICMP soft error: ignore and retry */
-            if (slen == 0)
-                r = send( fd, buf, len, 0 );
-            else
-                r = sendto( fd, buf, len, 0, peer, slen );
+            if( type == SOCK_DGRAM )
+            {
+                /* ICMP soft error: ignore and retry */
+                if (slen == 0)
+                    r = send( fd, buf, len, 0 );
+                else
+                    r = sendto( fd, buf, len, 0, peer, slen );
+            }
         }
     }
     return r;

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to