mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
LookupServer: Fix serializing name data in DNS answers
When serializing a RR of type PTR, we should use the DNS name serialization format, not a raw string.
This commit is contained in:
parent
d6f7ced4f1
commit
80f7489df0
3 changed files with 16 additions and 2 deletions
|
@ -92,8 +92,14 @@ ByteBuffer DNSPacket::to_byte_buffer() const
|
|||
stream << htons(answer.type());
|
||||
stream << htons(answer.class_code());
|
||||
stream << htonl(answer.ttl());
|
||||
stream << htons(answer.record_data().length());
|
||||
stream << answer.record_data().bytes();
|
||||
if (answer.type() == T_PTR) {
|
||||
DNSName name { answer.record_data() };
|
||||
stream << htons(name.serialized_size());
|
||||
stream << name;
|
||||
} else {
|
||||
stream << htons(answer.record_data().length());
|
||||
stream << answer.record_data().bytes();
|
||||
}
|
||||
}
|
||||
|
||||
return stream.copy_into_contiguous_buffer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue