From 0875d6e92308b33743b605a4dee56d7d64237523 Mon Sep 17 00:00:00 2001 From: Stephen Langasek Date: Mon, 14 Dec 1998 18:11:24 +0000 Subject: [PATCH] Prevent segfault in setsockopt when optname is SO_LINGER and optval is null. --- misc/winsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/winsock.c b/misc/winsock.c index 3f14b503585..cd2ced3f3dc 100644 --- a/misc/winsock.c +++ b/misc/winsock.c @@ -1477,10 +1477,12 @@ INT32 WINAPI WINSOCK_setsockopt32(SOCKET16 s, INT32 level, INT32 optname, struct linger linger; convert_sockopt(&level, &optname); - if (optname == SO_LINGER) { + if (optname == SO_LINGER && optval) { /* yes, uses unsigned short in both win16/win32 */ linger.l_onoff = ((UINT16*)optval)[0]; linger.l_linger = ((UINT16*)optval)[1]; + /* FIXME: what is documented behavior if SO_LINGER optval + is null?? */ optval = (char*)&linger; optlen = sizeof(struct linger); }