[vlc-commits] access: rist: check the return value of getsockopt
Sergio Ammirata
git at videolan.org
Fri Dec 7 09:50:06 CET 2018
vlc | branch: master | Sergio Ammirata <sergio at 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 <thomas at 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;
More information about the vlc-commits
mailing list