aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--util/ChangeLog8
-rw-r--r--util/Makefile.am8
-rw-r--r--util/srv.c22
3 files changed, 24 insertions, 14 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index af9d30ccd..6906fbc96 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-02 David Shaw <[email protected]>
+
+ * 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 <[email protected]>
* iobuf.c (fd_cache_synchronize): New. fsync() a file in cache.
diff --git a/util/Makefile.am b/util/Makefile.am
index 9907d4d03..329a06214 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -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@
diff --git a/util/srv.c b/util/srv.c
index 6b6e2116f..521b1c297 100644
--- a/util/srv.c
+++ b/util/srv.c
@@ -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;
}