projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
argmatch: port to C++
[gnulib.git]
/
lib
/
getsockname.c
diff --git
a/lib/getsockname.c
b/lib/getsockname.c
index
6520678
..
a5a0858
100644
(file)
--- a/
lib/getsockname.c
+++ b/
lib/getsockname.c
@@
-1,6
+1,6
@@
/* getsockname.c --- wrappers for Windows getsockname function
/* getsockname.c --- wrappers for Windows getsockname function
- Copyright (C) 2008
, 2009
Free Software Foundation, Inc.
+ Copyright (C) 2008
-2013
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
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
@@
-29,12
+29,21
@@
#undef getsockname
int
#undef getsockname
int
-rpl_getsockname (int fd, struct sockaddr *addr,
in
t *addrlen)
+rpl_getsockname (int fd, struct sockaddr *addr,
socklen_
t *addrlen)
{
SOCKET sock = FD_TO_SOCKET (fd);
{
SOCKET sock = FD_TO_SOCKET (fd);
- int r = getsockname (sock, addr, addrlen);
- if (r < 0)
- set_winsock_errno ();
- return r;
+ if (sock == INVALID_SOCKET)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ else
+ {
+ int r = getsockname (sock, addr, addrlen);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+ }
}
}