1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-20 01:02:44 +02:00

* Makefile.am: Make srv.c part of libcompat instead of libutil.

* srv.c (getsrv): Raise maximum packet size to 2048, as PACKETSZ is
too small these days.  Use libc malloc and free as we're part of
libcompat now which may not be linked to memory.c.
This commit is contained in:
David Shaw 2009-04-03 03:33:57 +00:00
parent c641585a42
commit 0f8b0fc195
3 changed files with 24 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2009-04-02 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: Make srv.c part of libcompat instead of libutil.
* srv.c (getsrv): Raise maximum packet size to 2048, as PACKETSZ
is too small these days. Use libc malloc and free as we're part
of libcompat now which may not be linked to memory.c.
2009-03-20 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (fd_cache_synchronize): New. fsync() a file in cache.

View File

@ -44,10 +44,6 @@ if USE_INTERNAL_REGEX
libutil_a_SOURCES+=regex.c
endif
if USE_DNS_SRV
libutil_a_SOURCES+=srv.c srv.h
endif
# The internal regex code #includes these.
EXTRA_libutil_a_SOURCES = regcomp.c regexec.c regex_internal.c \
regex_internal.h
@ -64,6 +60,10 @@ libcompat_a_SOURCES=compat.c
libcompat_a_DEPENDENCIES = @LIBOBJS@
libcompat_a_LIBADD = @LIBOBJS@
if USE_DNS_SRV
libcompat_a_SOURCES+=srv.c
endif
http-test: http.c
$(CC) -DHAVE_CONFIG_H $(CFLAGS) -I. $(INCLUDES) $(LDFLAGS) -g -Wall \
-DTEST -o http-test http.c libutil.a @LIBINTL@ @DNSLIBS@ @CAPLIBS@

View File

@ -1,5 +1,5 @@
/* srv.c - DNS SRV code
* Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
* Copyright (C) 2003, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
*
@ -31,8 +31,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "memory.h"
#include "types.h"
#include "srv.h"
/* Not every installation has gotten around to supporting SRVs
@ -56,15 +54,15 @@ priosort(const void *a,const void *b)
int
getsrv(const char *name,struct srventry **list)
{
unsigned char answer[PACKETSZ];
unsigned char answer[2048];
int r,srvcount=0;
unsigned char *pt,*emsg;
u16 count,dlen;
*list=NULL;
r=res_query(name,C_IN,T_SRV,answer,PACKETSZ);
if(r<sizeof(HEADER) || r>PACKETSZ)
r=res_query(name,C_IN,T_SRV,answer,2048);
if(r<sizeof(HEADER) || r>2048)
return -1;
if((((HEADER *)answer)->rcode)==NOERROR &&
@ -88,7 +86,11 @@ getsrv(const char *name,struct srventry **list)
struct srventry *srv=NULL;
u16 type,class;
*list=xrealloc(*list,(srvcount+1)*sizeof(struct srventry));
srv=realloc(*list,(srvcount+1)*sizeof(struct srventry));
if(!srv)
goto fail;
*list=srv;
memset(&(*list)[srvcount],0,sizeof(struct srventry));
srv=&(*list)[srvcount];
srvcount++;
@ -215,12 +217,12 @@ getsrv(const char *name,struct srventry **list)
return srvcount;
noanswer:
xfree(*list);
free(*list);
*list=NULL;
return 0;
fail:
xfree(*list);
free(*list);
*list=NULL;
return -1;
}
@ -243,7 +245,7 @@ main(int argc,char *argv[])
printf("\n");
}
xfree(srv);
free(srv);
return 0;
}