"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/ares-test.cc" between
c-ares-1.17.1.tar.gz and c-ares-1.17.2.tar.gz

About: c-ares is a C library for asynchronous DNS requests (including name resolves).

ares-test.cc  (c-ares-1.17.1):ares-test.cc  (c-ares-1.17.2)
#include "ares_setup.h"
#include "ares.h"
#include "ares_nameser.h"
#include "ares-test.h" #include "ares-test.h"
#include "ares-test-ai.h" #include "ares-test-ai.h"
#include "dns-proto.h" #include "dns-proto.h"
// Include ares internal files for DNS protocol details // Include ares internal files for DNS protocol details
#include "nameser.h"
#include "ares_dns.h" #include "ares_dns.h"
#ifdef HAVE_NETDB_H #ifdef HAVE_NETDB_H
#include <netdb.h> #include <netdb.h>
#endif #endif
#ifdef HAVE_NETINET_TCP_H #ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
skipping to change at line 137 skipping to change at line 139
fails_ >>= 1; fails_ >>= 1;
if (size_fails_[size] > 0) { if (size_fails_[size] > 0) {
size_fails_[size]--; size_fails_[size]--;
fail = true; fail = true;
} }
return fail; return fail;
} }
// static // static
void* LibraryTest::amalloc(size_t size) { void* LibraryTest::amalloc(size_t size) {
if (ShouldAllocFail(size)) { if (ShouldAllocFail(size) || size == 0) {
if (verbose) std::cerr << "Failing malloc(" << size << ") request" << std::e ndl; if (verbose) std::cerr << "Failing malloc(" << size << ") request" << std::e ndl;
return nullptr; return nullptr;
} else { } else {
return malloc(size); return malloc(size);
} }
} }
// static // static
void* LibraryTest::arealloc(void *ptr, size_t size) { void* LibraryTest::arealloc(void *ptr, size_t size) {
if (ShouldAllocFail(size)) { if (ShouldAllocFail(size)) {
skipping to change at line 314 skipping to change at line 316
// details. // details.
if (len < NS_HFIXEDSZ) { if (len < NS_HFIXEDSZ) {
std::cerr << "Packet too short (" << len << ")" << std::endl; std::cerr << "Packet too short (" << len << ")" << std::endl;
return; return;
} }
int qid = DNS_HEADER_QID(data); int qid = DNS_HEADER_QID(data);
if (DNS_HEADER_QR(data) != 0) { if (DNS_HEADER_QR(data) != 0) {
std::cerr << "Not a request" << std::endl; std::cerr << "Not a request" << std::endl;
return; return;
} }
if (DNS_HEADER_OPCODE(data) != ns_o_query) { if (DNS_HEADER_OPCODE(data) != O_QUERY) {
std::cerr << "Not a query (opcode " << DNS_HEADER_OPCODE(data) std::cerr << "Not a query (opcode " << DNS_HEADER_OPCODE(data)
<< ")" << std::endl; << ")" << std::endl;
return; return;
} }
if (DNS_HEADER_QDCOUNT(data) != 1) { if (DNS_HEADER_QDCOUNT(data) != 1) {
std::cerr << "Unexpected question count (" << DNS_HEADER_QDCOUNT(data) std::cerr << "Unexpected question count (" << DNS_HEADER_QDCOUNT(data)
<< ")" << std::endl; << ")" << std::endl;
return; return;
} }
byte* question = data + 12; byte* question = data + 12;
skipping to change at line 344 skipping to change at line 346
qlen -= enclen; qlen -= enclen;
question += enclen; question += enclen;
std::string namestr(name); std::string namestr(name);
ares_free_string(name); ares_free_string(name);
if (qlen < 4) { if (qlen < 4) {
std::cerr << "Unexpected question size (" << qlen std::cerr << "Unexpected question size (" << qlen
<< " bytes after name)" << std::endl; << " bytes after name)" << std::endl;
return; return;
} }
if (DNS_QUESTION_CLASS(question) != ns_c_in) { if (DNS_QUESTION_CLASS(question) != C_IN) {
std::cerr << "Unexpected question class (" << DNS_QUESTION_CLASS(question) std::cerr << "Unexpected question class (" << DNS_QUESTION_CLASS(question)
<< ")" << std::endl; << ")" << std::endl;
return; return;
} }
int rrtype = DNS_QUESTION_TYPE(question); int rrtype = DNS_QUESTION_TYPE(question);
if (verbose) { if (verbose) {
std::vector<byte> req(data, data + len); std::vector<byte> req(data, data + len);
std::cerr << "received " << (fd == udpfd_ ? "UDP" : "TCP") << " request " << PacketToString(req) std::cerr << "received " << (fd == udpfd_ ? "UDP" : "TCP") << " request " << PacketToString(req)
<< " on port " << (fd == udpfd_ ? udpport_ : tcpport_) << std::end l; << " on port " << (fd == udpfd_ ? udpport_ : tcpport_) << std::end l;
 End of changes. 5 change blocks. 
4 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)