gnupg/util (ChangeLog http.c)

cvs user dshaw cvs at cvs.gnupg.org
Sat Oct 16 23:28:43 CEST 2004


    Date: Saturday, October 16, 2004 @ 23:31:36
  Author: dshaw
    Path: /cvs/gnupg/gnupg/util

Modified: ChangeLog http.c

* http.c (connect_server): [_WIN32] actually fill in the sin_addr so we
aren't always talking to localhost.  Add some general sanity checking of
parameters learned from gethostbyname().


-----------+
 ChangeLog |    6 ++++++
 http.c    |   14 +++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)


Index: gnupg/util/ChangeLog
diff -u gnupg/util/ChangeLog:1.158 gnupg/util/ChangeLog:1.159
--- gnupg/util/ChangeLog:1.158	Fri Oct 15 11:38:27 2004
+++ gnupg/util/ChangeLog	Sat Oct 16 23:31:36 2004
@@ -1,3 +1,9 @@
+2004-10-16  David Shaw  <dshaw at jabberwocky.com>
+
+	* http.c (connect_server): [_WIN32] actually fill in the sin_addr
+	so we aren't always talking to localhost.  Add some general sanity
+	checking of parameters learned from gethostbyname().
+
 2004-10-15  Werner Koch  <wk at g10code.com>
 
 	* vasprintf.c: New.  Taken from gnupg 1.9.
Index: gnupg/util/http.c
diff -u gnupg/util/http.c:1.26 gnupg/util/http.c:1.27
--- gnupg/util/http.c:1.26	Fri Sep 10 23:16:47 2004
+++ gnupg/util/http.c	Sat Oct 16 23:31:36 2004
@@ -780,6 +780,7 @@
 
       addr.sin_family=AF_INET; 
       addr.sin_port=htons(port);
+      memcpy(&addr.sin_addr,&inaddr,sizeof(inaddr));      
 
       if(connect(sock,(struct sockaddr *)&addr,sizeof(addr))==0)
 	return sock;
@@ -797,7 +798,6 @@
     {
       /* We're using SRV, so append the tags */
       char srvname[MAXDNAME];
-
       strcpy(srvname,"_hkp._tcp.");
       strncat(srvname,server,MAXDNAME-11);
       srvname[MAXDNAME-1]='\0';
@@ -872,11 +872,23 @@
 	}
 
       addr.sin_family=host->h_addrtype;
+      if(addr.sin_family!=AF_INET)
+	{
+	  log_error("%s: unknown address family\n",srvlist[srv].target);
+	  return -1;
+	}
+
       addr.sin_port=htons(srvlist[srv].port);
 
       /* Try all A records until one responds. */
       while(host->h_addr_list[i])
 	{
+	  if(host->h_length!=4)
+	    {
+	      log_error("%s: illegal address length\n",srvlist[srv].target);
+	      return -1;
+	    }
+
 	  memcpy(&addr.sin_addr,host->h_addr_list[i],host->h_length);
 
 	  if(connect(sock,(struct sockaddr *)&addr,sizeof(addr))==0)




More information about the Gnupg-commits mailing list