summaryrefslogtreecommitdiff
path: root/lib/bind.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-03-05 10:06:12 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-03-05 10:06:12 +0900
commit1d8b652baba3df2da0eb42560205cab2ccb360e9 (patch)
treec546e30de11fdb2d144057d59b9c0d5f0f2539d5 /lib/bind.c
parent81f1c64e30d2ea59604a628bca9f1d04b1f82afb (diff)
downloadwget-1d8b652baba3df2da0eb42560205cab2ccb360e9.tar.gz
wget-1d8b652baba3df2da0eb42560205cab2ccb360e9.tar.bz2
wget-1d8b652baba3df2da0eb42560205cab2ccb360e9.zip
Imported Upstream version 1.14upstream/1.14
Diffstat (limited to 'lib/bind.c')
-rw-r--r--lib/bind.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/bind.c b/lib/bind.c
index e6d959d..0045c9d 100644
--- a/lib/bind.c
+++ b/lib/bind.c
@@ -1,6 +1,6 @@
/* bind.c --- wrappers for Windows bind function
- Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,9 +32,18 @@ int
rpl_bind (int fd, const struct sockaddr *sockaddr, socklen_t len)
{
SOCKET sock = FD_TO_SOCKET (fd);
- int r = bind (sock, sockaddr, len);
- if (r < 0)
- set_winsock_errno ();
- return r;
+ if (sock == INVALID_SOCKET)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ else
+ {
+ int r = bind (sock, sockaddr, len);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+ }
}