summaryrefslogtreecommitdiffstats
path: root/lib/sockopt.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/sockopt.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 41fcc41..74bc034 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -10,13 +10,12 @@
#include "sockunion.h"
#include "lib_errors.h"
-#if (defined(__FreeBSD__) \
- && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) \
- || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) \
- || (defined(__NetBSD__) && defined(__NetBSD_Version__) \
- && __NetBSD_Version__ >= 106010000) \
- || defined(__OpenBSD__) || defined(__APPLE__) \
- || defined(__DragonFly__) || defined(__sun)
+#if (defined(__FreeBSD__) && \
+ ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || \
+ (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || \
+ (defined(__NetBSD__) && defined(__NetBSD_Version__) && \
+ __NetBSD_Version__ >= 106010000) || \
+ defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun)
#define HAVE_BSD_STRUCT_IP_MREQ_HACK
#endif
@@ -673,6 +672,9 @@ int sockopt_tcp_mss_get(int sock)
int tcp_maxseg = 0;
socklen_t tcp_maxseg_len = sizeof(tcp_maxseg);
+ if (sock < 0)
+ return 0;
+
ret = getsockopt(sock, IPPROTO_TCP, TCP_MAXSEG, &tcp_maxseg,
&tcp_maxseg_len);
if (ret != 0) {