]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/gsocket.c
Typo fix
[wxWidgets.git] / src / unix / gsocket.c
index 3aa289c473dd036e33b5317176ada15340aeb519..85a38c699f63e7be550c976e24a5c2663d320272 100644 (file)
@@ -1499,7 +1499,9 @@ GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
   se = getservbyname(port, protocol);
   if (!se)
   {
-    if (isdigit(port[0]))
+    /* the cast to int suppresses compiler warnings about subscript having the
+       type char */
+    if (isdigit((int)port[0]))
     {
       int port_int;
 
@@ -1603,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;
@@ -1612,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;
 }