Skip to content
Snippets Groups Projects
Commit d26a57b6 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Added test with mangled DNS packets (packet size < header + minimal qst size)

parent fff38684
No related branches found
No related tags found
1 merge request!75Test case for merge request invalid_pktlen_checks
#!/usr/bin/env python3
'''DNS packet header parsing tests. '''
import socket
import dnstest
t = dnstest.DnsTest()
knot = t.server("knot")
zone = t.zone("example.com.")
t.link(zone, knot)
# Update configuration
knot.ratelimit = 5 # Check for crashes also in rate-limit code
t.start()
# Packet lengths shorter than DNS header
data = '\x00'
max_len = (12 + 5) # Header + minimal question size
udp_socket = knot.create_sock(socket.SOCK_DGRAM)
for i in range(1, max_len):
knot.send_raw(data * i, udp_socket)
udp_socket.close()
# Check if the server is still alive
resp = knot.dig("example.com", "SOA", timeout=5, tries=1)
resp.check(rcode="NOERROR")
t.end()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment