Commit 8d638e07 authored by Jelte Jansen's avatar Jelte Jansen

[trac697] add test for dns parse error in response

parent 32d47188
......@@ -101,11 +101,13 @@ public:
/// Set before the query and then by each "server" when responding.
enum QueryStatus {
NONE = 0, ///< Default
UDP_ROOT = 1, ///< Query root server over UDP
UDP_ORG = 2, ///< Query ORG server over UDP
TCP_ORG = 3, ///< Query ORG server over TCP
UDP_EXAMPLE_ORG = 4, ///< Query EXAMPLE.ORG server over UDP
COMPLETE = 5 ///< Query is complete
UDP_ROOT, ///< Query root server over UDP
UDP_ORG, ///< Query ORG server over UDP
TCP_ORG, ///< Query ORG server over TCP
UDP_EXAMPLE_ORG_BAD, ///< Query EXAMPLE.ORG server over UDP
///< (return malformed packet)
UDP_EXAMPLE_ORG, ///< Query EXAMPLE.ORG server over UDP
COMPLETE ///< Query is complete
};
// Common stuff
......@@ -305,6 +307,12 @@ public:
expected_ = TCP_ORG;
break;
case UDP_EXAMPLE_ORG_BAD:
// Return the answer to the question.
setAnswerWwwExampleOrg(msg);
// Set new expected in check below
break;
case UDP_EXAMPLE_ORG:
// Return the answer to the question.
setAnswerWwwExampleOrg(msg);
......@@ -320,6 +328,13 @@ public:
MessageRenderer renderer(*udp_send_buffer_);
msg.toWire(renderer);
if (expected_ == UDP_EXAMPLE_ORG_BAD) {
// mangle the packet a bit
// set additional to one more
udp_send_buffer_->writeUint8At(3, 11);
expected_ = UDP_EXAMPLE_ORG;
}
// Return a message back to the IOFetch object (after setting the
// expected length of data for the check in the send handler).
udp_length_ = udp_send_buffer_->getLength();
......@@ -450,7 +465,7 @@ public:
// readiness for the next read. (If any - at present, there is only
// one read in the test, although extensions to this test suite could
// change that.)
expected_ = UDP_EXAMPLE_ORG;
expected_ = UDP_EXAMPLE_ORG_BAD;
tcp_cumulative_ = 0;
// Unless we go through a callback loop we cannot simply use
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment