]> code.delx.au - gnu-emacs/blobdiff - src/process.c
(find_field): Fix comment.
[gnu-emacs] / src / process.c
index 29c93052369c49fab11bc70ee1fddde974d2b327..dbb431496c3c34e8d3bf9f2f6f93b4f6391c4c3d 100644 (file)
@@ -2322,9 +2322,11 @@ get_lisp_to_sockaddr_size (address, familyp)
 }
 
 /* Convert an address object (vector or string) to an internal sockaddr.
-   Address format has already been validated by get_lisp_to_sockaddr_size,
-   but just to be nice, we return without doing anything
-   if FAMILY is not valid.  */
+
+   The address format has been basically validated by
+   get_lisp_to_sockaddr_size, but this does not mean FAMILY is valid;
+   it could have come from user data.  So if FAMILY is not valid,
+   we return after zeroing *SA.  */
 
 static void
 conv_lisp_to_sockaddr (family, address, sa, len)
@@ -2338,7 +2340,6 @@ conv_lisp_to_sockaddr (family, address, sa, len)
   register int i;
 
   bzero (sa, len);
-  sa->sa_family = family;
 
   if (VECTORP (address))
     {
@@ -2350,6 +2351,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
          i = XINT (p->contents[--len]);
          sin->sin_port = htons (i);
          cp = (unsigned char *)&sin->sin_addr;
+         sa->sa_family = family;
        }
 #ifdef AF_INET6
       else if (family == AF_INET6)
@@ -2365,7 +2367,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
                int j = XFASTINT (p->contents[i]) & 0xffff;
                ip6[i] = ntohs (j);
              }
-         return;
+         sa->sa_family = family;
        }
 #endif
       return;
@@ -2379,6 +2381,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
          cp = SDATA (address);
          for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
            sockun->sun_path[i] = *cp++;
+         sa->sa_family = family;
        }
 #endif
       return;
@@ -6234,6 +6237,8 @@ text to PROCESS after you call this function.  */)
       emacs_close (XINT (XPROCESS (proc)->outfd));
 #endif /* not HAVE_SHUTDOWN */
       new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
+      if (new_outfd < 0)
+       abort ();
       old_outfd = XINT (XPROCESS (proc)->outfd);
 
       if (!proc_encode_coding_system[new_outfd])