fixed bug with not NUL-terminating the string in GAddress_UNIX_SetPath

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15113 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2002-04-12 14:18:51 +00:00
parent bb28b47763
commit 70914290a1

View File

@ -1605,6 +1605,8 @@ GSocketError _GAddress_Init_UNIX(GAddress *address)
return GSOCK_NOERROR;
}
#define UNIX_SOCK_PATHLEN (sizeof(addr->sun_path)/sizeof(addr->sun_path[0]))
GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
{
struct sockaddr_un *addr;
@ -1614,7 +1616,8 @@ GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
CHECK_ADDRESS(address, UNIX);
addr = ((struct sockaddr_un *)address->m_addr);
memcpy(addr->sun_path, path, strlen(path));
strncpy(addr->sun_path, path, UNIX_SOCK_PATHLEN);
addr->sun_path[UNIX_SOCK_PATHLEN - 1] = '\0';
return GSOCK_NOERROR;
}