Skip to content

Commit

Permalink
For #909: Numeric truncation when parsing TYPEXX and CLASSXX represen…
Browse files Browse the repository at this point in the history
…tation

- Fix return values.
- Formatting nits.
  • Loading branch information
gthess committed Jul 20, 2023
1 parent d29bc71 commit 5b7faca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion daemon/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ do_flush_type(RES* ssl, struct worker* worker, char* arg)
return;
t = sldns_get_rr_type_by_name(arg2);
if(t == 0 && strcmp(arg2, "TYPE0") != 0) {
return 0;
return;
}
do_cache_remove(worker, nm, nmlen, t, LDNS_RR_CLASS_IN);

Expand Down
11 changes: 7 additions & 4 deletions testcode/dohclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,15 @@ make_query(char* qname, char* qtype, char* qclass)
printf("cannot parse query name: '%s'\n", qname);
exit(1);
}

qinfo.qtype = sldns_get_rr_type_by_name(qtype);
if(qinfo.qtype == 0 && strcmp(qtype, "TYPE0") != 0) {
printf("cannot parse query type: '%s'\n", qtype);
exit(1);
}
qinfo.qclass = sldns_get_rr_class_by_name(qclass);
if((qinfo.qtype == 0 && strcmp(qtype, "TYPE0") != 0) ||
(qinfo.qclass == 0 && strcmp(qclass, "CLASS0") != 0)) {
return 0;
if(qinfo.qclass == 0 && strcmp(qclass, "CLASS0") != 0) {
printf("cannot parse query class: '%s'\n", qclass);
exit(1);
}
qinfo.local_alias = NULL;

Expand Down
4 changes: 2 additions & 2 deletions testcode/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,14 @@ qlist_parse_line(sldns_buffer* buf, char* p)
qinfo.qtype = sldns_get_rr_type_by_name(cl);
qinfo.qclass = sldns_get_rr_class_by_name(tp);
if((qinfo.qtype == 0 && strcmp(cl, "TYPE0") != 0) ||
(qinfo.qclass == 0 && strcmp(tp, "CLASS0") != 0)) {
(qinfo.qclass == 0 && strcmp(tp, "CLASS0") != 0)) {
return 0;
}
} else {
qinfo.qtype = sldns_get_rr_type_by_name(tp);
qinfo.qclass = sldns_get_rr_class_by_name(cl);
if((qinfo.qtype == 0 && strcmp(tp, "TYPE0") != 0) ||
(qinfo.qclass == 0 && strcmp(cl, "CLASS0") != 0)) {
(qinfo.qclass == 0 && strcmp(cl, "CLASS0") != 0)) {
return 0;
}
}
Expand Down
10 changes: 7 additions & 3 deletions testcode/streamtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ write_q(int fd, int udp, SSL* ssl, sldns_buffer* buf, uint16_t id,

/* qtype and qclass */
qinfo.qtype = sldns_get_rr_type_by_name(strtype);
if(qinfo.qtype == 0 && strcmp(strtype, "TYPE0") != 0) {
printf("cannot parse query type: '%s'\n", strtype);
exit(1);
}
qinfo.qclass = sldns_get_rr_class_by_name(strclass);
if((qinfo.qtype == 0 && strcmp(strtype, "TYPE0") != 0) ||
(qinfo.qclass == 0 && strcmp(strclass, "CLASS0") != 0)) {
return 0;
if(qinfo.qclass == 0 && strcmp(strclass, "CLASS0") != 0) {
printf("cannot parse query class: '%s'\n", strclass);
exit(1);
}

/* clear local alias */
Expand Down

0 comments on commit 5b7faca

Please sign in to comment.