]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
For #909: Numeric truncation when parsing TYPEXX and CLASSXX representation
authorGeorge Thessalonikefs <george@nlnetlabs.nl>
Thu, 20 Jul 2023 09:42:05 +0000 (11:42 +0200)
committerGeorge Thessalonikefs <george@nlnetlabs.nl>
Thu, 20 Jul 2023 09:42:05 +0000 (11:42 +0200)
- Fix return values.
- Formatting nits.

daemon/remote.c
testcode/dohclient.c
testcode/perf.c
testcode/streamtcp.c

index f27111fee38af59b3aa147ca5a2c45a0b648d0d3..c7bfa4e128f445db456eaed58978a6a77af1290e 100644 (file)
@@ -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);
 
index 2ee3be8e5f571544396020acaa6c7feadf8cc6ed..de9f39d7d941f7d2b87182b24bba7640ca26882a 100644 (file)
@@ -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;
 
index 5a4b3949132f6b46fd624067a370b54ca675ef0f..2be86c4bf597c11f1939302ce9c7811a2acc1473 100644 (file)
@@ -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;
                }
        }
index 5e54894a6e37ad0e5c9ab646e0ba6496399b8a56..4eee14187b9704d7bc2d611dc01a0d3765738c79 100644 (file)
@@ -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 */