1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-08 12:44:23 +01:00

* 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().
This commit is contained in:
David Shaw 2004-10-16 21:31:36 +00:00
parent a2cd03ffe1
commit 4d79b138ac
2 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2004-10-16 David Shaw <dshaw@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@g10code.com>
* vasprintf.c: New. Taken from gnupg 1.9.

View File

@ -780,6 +780,7 @@ connect_server( const char *server, ushort port, unsigned int flags )
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 @@ connect_server( const char *server, ushort port, unsigned int flags )
{
/* 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 @@ connect_server( const char *server, ushort port, unsigned int flags )
}
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)