From 732201ca09b0d99ab68ec9613542fa72e6db3c1d Mon Sep 17 00:00:00 2001 From: Sergio Ammirata Date: Tue, 27 Nov 2018 08:15:28 -0500 Subject: [PATCH] access: rist: check the return value of getsockopt Signed-off-by: Thomas Guillem --- 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; -- 2.11.4.GIT