X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/2953d358511ac5d196362f6b339c010d4e9cae3e..cca882a1f039a32ced374e3d29cd8da9f0e19954:/src/transmit.c diff --git a/src/transmit.c b/src/transmit.c index c669af6..08e49d0 100644 --- a/src/transmit.c +++ b/src/transmit.c @@ -5,10 +5,10 @@ */ /* * This file is - * Copyright (C) 1997-1999 Ian Jackson + * Copyright (C) 1997-2000 Ian Jackson * * It is part of adns, which is - * Copyright (C) 1997-1999 Ian Jackson + * Copyright (C) 1997-2000 Ian Jackson * Copyright (C) 1999 Tony Finch * * This program is free software; you can redistribute it and/or modify @@ -77,7 +77,7 @@ static adns_status mkquery_footer(vbuf *vb, adns_rrtype type) { adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r, const char *owner, int ol, const typeinfo *typei, adns_queryflags flags) { - int ll, c, nlabs; + int ll, c, nbytes; byte label[255], *rqp; const char *p, *pe; adns_status st; @@ -87,7 +87,7 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r, MKQUERY_START(vb); p= owner; pe= owner+ol; - nlabs= 0; + nbytes= 0; while (p!=pe) { ll= 0; while (p!=pe && (c= *p++)!='.') { @@ -115,7 +115,9 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r, label[ll++]= c; } if (!ll) return adns_s_querydomaininvalid; - if (nlabs++ > 63) return adns_s_querydomaintoolong; + if (ll > DNS_MAXLABEL) return adns_s_querydomaintoolong; + nbytes+= ll+1; + if (nbytes >= DNS_MAXDOMAIN) return adns_s_querydomaintoolong; MKQUERY_ADDB(ll); memcpy(rqp,label,ll); rqp+= ll; } @@ -246,7 +248,7 @@ void adns__query_send(adns_query qu, struct timeval now) { r= sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0, (const struct sockaddr*)&servaddr,sizeof(servaddr)); if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; } - if (r<0) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno)); + if (r<0 && errno != EAGAIN) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno)); qu->timeout= now; timevaladd(&qu->timeout,UDPRETRYMS);