* net.cc (cygwin_getsockname): Fix handling of NULL sun_path.
This commit is contained in:
parent
7a149da931
commit
1f64102fa6
@ -1,3 +1,7 @@
|
|||||||
|
2002-02-07 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* net.cc (cygwin_getsockname): Fix handling of NULL sun_path.
|
||||||
|
|
||||||
2002-01-29 Corinna Vinschen <corinna@vinschen.de>
|
2002-01-29 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* net.cc (getdomainname): Fix registry key for 9x systems, too.
|
* net.cc (getdomainname): Fix registry key for 9x systems, too.
|
||||||
|
@ -1375,12 +1375,17 @@ cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen)
|
|||||||
struct sockaddr_un *sun = (struct sockaddr_un *) addr;
|
struct sockaddr_un *sun = (struct sockaddr_un *) addr;
|
||||||
memset (sun, 0, *namelen);
|
memset (sun, 0, *namelen);
|
||||||
sun->sun_family = AF_LOCAL;
|
sun->sun_family = AF_LOCAL;
|
||||||
/* According to SUSv2 "If the actual length of the address is greater
|
|
||||||
than the length of the supplied sockaddr structure, the stored
|
if (!sock->get_sun_path ())
|
||||||
address will be truncated." We play it save here so that the
|
sun->sun_path[0] = '\0';
|
||||||
path always has a trailing 0 even if it's truncated. */
|
else
|
||||||
strncpy (sun->sun_path, sock->get_sun_path (),
|
/* According to SUSv2 "If the actual length of the address is
|
||||||
*namelen - sizeof *sun + sizeof sun->sun_path - 1);
|
greater than the length of the supplied sockaddr structure, the
|
||||||
|
stored address will be truncated." We play it save here so
|
||||||
|
that the path always has a trailing 0 even if it's truncated. */
|
||||||
|
strncpy (sun->sun_path, sock->get_sun_path (),
|
||||||
|
*namelen - sizeof *sun + sizeof sun->sun_path - 1);
|
||||||
|
|
||||||
*namelen = sizeof *sun - sizeof sun->sun_path
|
*namelen = sizeof *sun - sizeof sun->sun_path
|
||||||
+ strlen (sun->sun_path) + 1;
|
+ strlen (sun->sun_path) + 1;
|
||||||
res = 0;
|
res = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user