Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000066 [MyDNS-NG] Global minor always 2011-06-21 13:07 2014-08-05 23:38
Reporter muth1987 View Status public  
Assigned To jameno123
Priority normal Resolution open  
Status feedback   Product Version
Summary 0000066: TLD added twice in the answer of the authority section
Description I suppose that I have found a bug in the current version of mydns-ng (1.2.8.31).

While querying the zone "www.example.com." I get the following results:

dig www.example.com @<SERVER>

----------------------------------------
;; QUESTION SECTION:
;www.example.com. IN A

;; AUTHORITY SECTION:
www.example.com.example.com. 3600 IN NS dns1.example.com.
www.example.com.example.com. 3600 IN NS dns2.example.com.
www.example.com.example.com. 3600 IN NS dns3.example.com.

;; ADDITIONAL SECTION:
dns3.example.com. 3600 IN A 127.0.0.3
dns1.example.com. 3600 IN A 127.0.0.1
dns2.example.com. 3600 IN A 127.0.0.2
----------------------------------------

It seems that the TLD (example.com.) has been added twice in the answer of the AUTHORITY SECTION.
The same bug is reported by the following URL:
http://mydns-ng.com/mantis/view.php?id=43 [^]

The MySQL-Database records follow:

----------------------------------------
INSERT INTO `rr` VALUES(1362013, 'Y', 260676, 'www.example.com.', 'dns1.example.com.', 0, 3600, 'NS', NULL);
INSERT INTO `rr` VALUES(1362014, 'Y', 260676, 'www.example.com.', 'dns2.example.com.', 0, 3600, 'NS', NULL);
INSERT INTO `rr` VALUES(1362015, 'Y', 260676, 'www.example.com.', 'dns3.example.com.', 0, 3600, 'NS', NULL);
INSERT INTO `rr` VALUES(1355099, 'Y', 260676, 'dns1.example.com.', '127.0.0.1', 0, 3600, 'A', NULL);
INSERT INTO `rr` VALUES(1355100, 'Y', 260676, 'dns2.example.com.', '127.0.0.2', 0, 3600, 'A', NULL);
INSERT INTO `rr` VALUES(1355101, 'Y', 260676, 'dns3.example.com.', '127.0.0.3', 0, 3600, 'A', NULL);

INSERT INTO `soa` VALUES(260676, 'Y', 'example.com.', 'dns1.example.com.', 'hostmaster.example.com.', 2011061602, 86400, 7200, 3600000, 1800, 3600);
----------------------------------------

I have also found a difference between "dig" and "nslookup" or "host" queries.

Trying "www.example.com"

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43197
;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 3

;; QUESTION SECTION:
;www.example.com. IN ANY

;; ANSWER SECTION:
www.example.com. 3600 IN NS dns1.example.com.
www.example.com. 3600 IN NS dns2.example.com.
www.example.com. 3600 IN NS dns3.example.com.

;; ADDITIONAL SECTION:
dns1.example.com. 3600 IN A 127.0.0.1
dns2.example.com. 3600 IN A 127.0.0.2
dns3.example.com. 3600 IN A 127.0.0.3

The bug only appears to be with "dig" and not with "nslookup" or "host"
as queries from "host" and "nslookup" do not match the condition on line 192 of the file "src/mydns/resolve.c":

"if (r->type == DNS_QTYPE_NS && add_ns) {"

By using "dig" this condition will be matched and the TLD added twice.
I don't know if my patch is correct, but it works for me. In the line 198 of "src/mydns/resolve.c" I have changed the code as follows:

OLD:
----------------------------------------
else if (MYDNS_RR_NAME(r)[0] && MYDNS_RR_NAME(r)[0] != '*')
      ASPRINTF(&ns, "%s.%s", MYDNS_RR_NAME(r), soa->origin);
else
      ns = STRDUP(soa->origin);
----------------------------------------

NEW:
----------------------------------------
else if (MYDNS_RR_NAME(r)[0] && MYDNS_RR_NAME(r)[0] != '*')
     if (LASTCHAR((char*)MYDNS_RR_NAME(r)) == '.') {
         ASPRINTF(&ns, "%s", MYDNS_RR_NAME(r), soa->origin);
     }
     else {
         ASPRINTF(&ns, "%s.%s", MYDNS_RR_NAME(r), soa->origin);
     }
else {
     ns = STRDUP(soa->origin);
----------------------------------------

Could you please check the bugfix?
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0000198)
vandalite (reporter)
2014-06-04 20:23

I have been able to reproduce this issue on our servers. It's a cPanel server with this version of mydns-ng installed, and I was able to reproduce this with both dig and nslookup. It seems the bug only occurs when you query anything but the 'NS' record for a delegated subdomain. If you query for the 'NS' record, you get the correct results.

I've modified the results swapping out the domain for 'example.com' and the host server name as 'host.com', and the delegated nameservers as 'host2.com' for privacy reasons:

> set type=NS
> server ns1.host.com
> corp.example.com.

corp.example.com nameserver = ns1.host2.com
corp.example.com nameserver = ns2.host2.com
corp.example.com nameserver = ns3.host2.com
corp.example.com nameserver = ns4.host2.com
> set type=A
> corp.example.com.

Name: corp.example.com
Served by:
- ns1131.host2.com

          corp.example.com.example.com
- ns2164.host2.com

          corp.example.com.example.com
- ns3151.host2.com

          corp.example.com.example.com
- ns4190.host2.com

          corp.example.com.example.com
(0000201)
jameno123 (administrator)
2014-08-05 20:47
edited on: 2014-08-05 20:49

vandalite: Could you please post the SQL structure of the database and the raw SQL dump of said reproduction? I am trying to reproduce this and each time its returning correctly.

Are you trying with the latest git(master) code?


(For the looks of it) The values in the test-case indicate an error in the data imported in the SQL database (if i am reading it correctly)... The name field is set to "www.example.com." which will expand to "www.example.com.example.com".

INSERT INTO `rr` VALUES(1362013, 'Y', 260676, 'www.example.com.', 'dns1.example.com.', 0, 3600, 'NS', NULL);
INSERT INTO `rr` VALUES(1362014, 'Y', 260676, 'www.example.com.', 'dns2.example.com.', 0, 3600, 'NS', NULL);
INSERT INTO `rr` VALUES(1362015, 'Y', 260676, 'www.example.com.', 'dns3.example.com.', 0, 3600, 'NS', NULL);


- Issue History
Date Modified Username Field Change
2011-06-21 13:07 muth1987 New Issue
2014-06-04 20:23 vandalite Note Added: 0000198
2014-06-04 20:25 vandalite Issue Monitored: vandalite
2014-08-05 20:47 jameno123 Note Added: 0000201
2014-08-05 20:49 jameno123 Note Edited: 0000201
2014-08-05 23:38 jameno123 Assigned To => jameno123
2014-08-05 23:38 jameno123 Status new => feedback


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker