Skip to content

Commit 6058483

Browse files
committed
Reject replies to DNS PTR requests that contain invalid characters
Fixes issue #1033 reported by @ping86
1 parent 4dd7fb6 commit 6058483

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/dns.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,16 @@ DNSResult DNS::GetResult()
700700
/* Identical handling to PTR */
701701

702702
case DNS_QUERY_PTR:
703+
{
703704
/* Reverse lookups just come back as char* */
704705
resultstr = std::string((const char*)data.first);
706+
if (resultstr.find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") != std::string::npos)
707+
{
708+
std::string ro = req->orig;
709+
delete req;
710+
return DNSResult(this_id | ERROR_MASK, "Invalid char(s) in reply", 0, ro);
711+
}
712+
}
705713
break;
706714

707715
default:

0 commit comments

Comments
 (0)