summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
47eed01)
+ * Better checking of long domain names and labels in queries.
+ * Unfortunately, answer->owner may be null on error. Documented.
* README updated (from www home page).
* Better reporting of unexpected or weird replies from nameserver.
* README updated (from www home page).
* Better reporting of unexpected or weird replies from nameserver.
+ * Better checking of long domain names and labels in queries.
+ * Unfortunately, answer->owner may be null on error. Documented.
if (!inet_aton(arg,&sa.sin_addr)) usageerr("invalid IP address %s",arg);
prep_query(&qun,&quflags);
if (!inet_aton(arg,&sa.sin_addr)) usageerr("invalid IP address %s",arg);
prep_query(&qun,&quflags);
+ qun->owner= xstrsave(arg);
r= adns_submit_reverse(ads,
(struct sockaddr*)&sa,
ov_type == adns_r_none ? adns_r_ptr : ov_type,
r= adns_submit_reverse(ads,
(struct sockaddr*)&sa,
ov_type == adns_r_none ? adns_r_ptr : ov_type,
int quflags, r;
prep_query(&qun,&quflags);
int quflags, r;
prep_query(&qun,&quflags);
+ qun->owner= xstrsave(domain);
r= adns_submit(ads, domain,
ov_type == adns_r_none ? adns_r_addr : ov_type,
quflags,
r= adns_submit(ads, domain,
ov_type == adns_r_none ? adns_r_addr : ov_type,
quflags,
if (printf("%lu ",ttl) == EOF) outerr();
}
if (printf("%lu ",ttl) == EOF) outerr();
}
+static const char *owner_show(struct query_node *qun, adns_answer *answer) {
+ return answer->owner ? answer->owner : qun->owner;
+}
+
static void print_owner_ttl(struct query_node *qun, adns_answer *answer) {
static void print_owner_ttl(struct query_node *qun, adns_answer *answer) {
- if (qun->pqfr.show_owner) print_withspace(answer->owner);
+ if (qun->pqfr.show_owner) print_withspace(owner_show(qun,answer));
}
assert(ov_format == fmt_simple);
if (st == adns_s_nxdomain) {
}
assert(ov_format == fmt_simple);
if (st == adns_s_nxdomain) {
- r= fprintf(stderr,"%s does not exist\n", answer->owner);
+ r= fprintf(stderr,"%s does not exist\n", owner_show(qun,answer));
} else {
ist= adns_rr_info(answer->type, &typename, 0,0,0,0);
if (st == adns_s_nodata) {
} else {
ist= adns_rr_info(answer->type, &typename, 0,0,0,0);
if (st == adns_s_nodata) {
- r= fprintf(stderr,"%s has no %s record\n", answer->owner, typename);
+ r= fprintf(stderr,"%s has no %s record\n", owner_show(qun,answer), typename);
} else {
statusstring= adns_strerror(st);
r= fprintf(stderr,"Error during DNS %s lookup for %s: %s\n",
} else {
statusstring= adns_strerror(st);
r= fprintf(stderr,"Error during DNS %s lookup for %s: %s\n",
- typename, answer->owner, statusstring);
+ typename, owner_show(qun,answer), statusstring);
}
}
if (r == EOF) sysfail("write error message to stderr",errno);
}
}
if (r == EOF) sysfail("write error message to stderr",errno);
}
}
if (qun->pqfr.show_owner) {
}
}
if (qun->pqfr.show_owner) {
- realowner= answer->cname ? answer->cname : answer->owner;
+ realowner= answer->cname ? answer->cname : owner_show(qun,answer);
assert(realowner);
} else {
realowner= 0;
assert(realowner);
} else {
realowner= 0;
struct query_node {
struct query_node *next, *back;
struct perqueryflags_remember pqfr;
struct query_node {
struct query_node *next, *back;
struct perqueryflags_remember pqfr;
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
- * $Id: adns.h,v 1.73 1999/11/07 19:15:36 ian Exp $
+ * $Id: adns.h,v 1.74 2000/03/01 23:50:05 ian Exp $
*/
#ifndef ADNS_H_INCLUDED
*/
#ifndef ADNS_H_INCLUDED
typedef struct {
adns_status status;
char *cname; /* always NULL if query was for CNAME records */
typedef struct {
adns_status status;
char *cname; /* always NULL if query was for CNAME records */
- char *owner; /* only set if requested in query flags */
+ char *owner; /* only set if requested in query flags, and may be 0 on error anyway */
adns_rrtype type; /* guaranteed to be same as in query */
time_t expires; /* expiry time, defined only if _s_ok, nxdomain or nodata. NOT TTL! */
int nrrs, rrsz; /* nrrs is 0 if an error occurs */
adns_rrtype type; /* guaranteed to be same as in query */
time_t expires; /* expiry time, defined only if _s_ok, nxdomain or nodata. NOT TTL! */
int nrrs, rrsz; /* nrrs is 0 if an error occurs */
SINFO( querydomainwrong, "Domain invalid for particular DNS query type" ),
SINFO( querydomaininvalid, "Domain name is syntactically invalid" ),
SINFO( querydomainwrong, "Domain invalid for particular DNS query type" ),
SINFO( querydomaininvalid, "Domain name is syntactically invalid" ),
- SINFO( querydomaintoolong, "Domain name is too long" ),
+ SINFO( querydomaintoolong, "Domain name or component is too long" ),
SINFO( nxdomain, "No such domain" ),
SINFO( nodata, "No such data" )
SINFO( nxdomain, "No such domain" ),
SINFO( nodata, "No such data" )
adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
const char *owner, int ol,
const typeinfo *typei, adns_queryflags flags) {
adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
const char *owner, int ol,
const typeinfo *typei, adns_queryflags flags) {
byte label[255], *rqp;
const char *p, *pe;
adns_status st;
byte label[255], *rqp;
const char *p, *pe;
adns_status st;
MKQUERY_START(vb);
p= owner; pe= owner+ol;
MKQUERY_START(vb);
p= owner; pe= owner+ol;
while (p!=pe) {
ll= 0;
while (p!=pe && (c= *p++)!='.') {
while (p!=pe) {
ll= 0;
while (p!=pe && (c= *p++)!='.') {
label[ll++]= c;
}
if (!ll) return adns_s_querydomaininvalid;
label[ll++]= c;
}
if (!ll) return adns_s_querydomaininvalid;
- if (nlabs++ > 63) return adns_s_querydomaintoolong;
+ if (ll > 63) return adns_s_querydomaintoolong;
+ nbytes+= ll+1;
+ if (nbytes > 254) return adns_s_querydomaintoolong;
MKQUERY_ADDB(ll);
memcpy(rqp,label,ll); rqp+= ll;
}
MKQUERY_ADDB(ll);
memcpy(rqp,label,ll); rqp+= ll;
}