From: ian Date: Sun, 8 Nov 1998 16:57:53 +0000 (+0000) Subject: Bugfixes. X-Git-Tag: abandon.1999-04-10.multithread~45 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=commitdiff_plain;h=9557e604273fc0ce783fe69da74858b37ae818e5 Bugfixes. --- diff --git a/src/Makefile b/src/Makefile index 59ccf54..acce334 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -CC=gcc $(WARNS) $(WERROR) $(OPTIMISE) $(DEBUG) +CC=gcc $(WARNS) $(WERROR) $(OPTIMISE) $(DEBUG) $(XCFLAGS) DEBUG=-g OPTIMISE=-O2 WARNS= -Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes \ diff --git a/src/Makefile.in b/src/Makefile.in index 59ccf54..acce334 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -CC=gcc $(WARNS) $(WERROR) $(OPTIMISE) $(DEBUG) +CC=gcc $(WARNS) $(WERROR) $(OPTIMISE) $(DEBUG) $(XCFLAGS) DEBUG=-g OPTIMISE=-O2 WARNS= -Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes \ diff --git a/src/general.c b/src/general.c index 09b63e6..efad813 100644 --- a/src/general.c +++ b/src/general.c @@ -125,7 +125,7 @@ int adns__vbuf_append(vbuf *vb, const byte *data, int len) { int adns__vbuf_appendstr(vbuf *vb, const char *data) { int l; - l= strlen(data)+1; + l= strlen(data); return adns__vbuf_append(vb,data,l); } diff --git a/src/internal.h b/src/internal.h index a20dd93..257953f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -239,7 +239,7 @@ void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt, ...) PRINTFFORMAT(4,5); int adns__vbuf_ensure(vbuf *vb, int want); -int adns__vbuf_appendstr(vbuf *vb, const char *data); +int adns__vbuf_appendstr(vbuf *vb, const char *data); /* does not include nul */ int adns__vbuf_append(vbuf *vb, const byte *data, int len); /* 1=>success, 0=>realloc failed */ void adns__vbuf_appendq(vbuf *vb, const byte *data, int len); diff --git a/src/query.c b/src/query.c index 1d4dc5f..92bb228 100644 --- a/src/query.c +++ b/src/query.c @@ -200,7 +200,7 @@ void *adns__alloc_final(adns_query qu, size_t sz) { } void adns__reset_cnameonly(adns_query qu) { - assert(qu->final_allocspace); + assert(!qu->final_allocspace); qu->answer->nrrs= 0; qu->answer->rrs= 0; qu->interim_allocd= qu->answer->cname ? MEM_ROUND(strlen(qu->answer->cname)+1) : 0; @@ -242,6 +242,7 @@ void adns__makefinal_str(adns_query qu, char **strp) { char *before, *after; before= *strp; + if (!before) return; l= strlen(before)+1; after= adns__alloc_final(qu,l); memcpy(after,before,l); @@ -249,10 +250,12 @@ void adns__makefinal_str(adns_query qu, char **strp) { } void adns__makefinal_block(adns_query qu, void **blpp, size_t sz) { - void *after; + void *before, *after; + before= *blpp; + if (!before) return; after= adns__alloc_final(qu,sz); - memcpy(after,*blpp,sz); + memcpy(after,before,sz); *blpp= after; } diff --git a/src/reply.c b/src/reply.c index 2317954..cbb66a1 100644 --- a/src/reply.c +++ b/src/reply.c @@ -41,6 +41,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, adns__diag(ads,serv,0,"received datagram too short for message header (%d)",dglen); return; } + cbyte= 0; GET_W(cbyte,id); GET_B(cbyte,f1); GET_B(cbyte,f2); @@ -57,7 +58,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, flg_ra= f2&0x80; rcode= (f1&0x0f); - if (flg_qr) { + if (!flg_qr) { adns__diag(ads,serv,0,"server sent us a query, not a response"); return; }