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

[trac697] add test for dns parse error in response

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