X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/72c71d39724af116d419295b684dd2946efb3da3..2d956b58023a4955313a1c1531bc70a0deb0b831:/src/unix/gsocket.c diff --git a/src/unix/gsocket.c b/src/unix/gsocket.c index 0da32b61eb..85a38c699f 100644 --- a/src/unix/gsocket.c +++ b/src/unix/gsocket.c @@ -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; }