| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qdnslookup_p.h" | - |
| 43 | | - |
| 44 | #include <qlibrary.h> | - |
| 45 | #include <qscopedpointer.h> | - |
| 46 | #include <qurl.h> | - |
| 47 | #include <private/qmutexpool_p.h> | - |
| 48 | | - |
| 49 | #include <sys/types.h> | - |
| 50 | #include <netinet/in.h> | - |
| 51 | #include <arpa/nameser.h> | - |
| 52 | #include <arpa/nameser_compat.h> | - |
| 53 | #include <resolv.h> | - |
| 54 | | - |
| 55 | QT_BEGIN_NAMESPACE | - |
| 56 | | - |
| 57 | #ifndef QT_NO_LIBRARY | - |
| 58 | | - |
| 59 | typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); | - |
| 60 | static dn_expand_proto local_dn_expand = 0; | - |
| 61 | typedef void (*res_nclose_proto)(res_state); | - |
| 62 | static res_nclose_proto local_res_nclose = 0; | - |
| 63 | typedef int (*res_ninit_proto)(res_state); | - |
| 64 | static res_ninit_proto local_res_ninit = 0; | - |
| 65 | typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); | - |
| 66 | static res_nquery_proto local_res_nquery = 0; | - |
| 67 | | - |
| 68 | // Custom deleter to close resolver state. | - |
| 69 | | - |
| 70 | struct QDnsLookupStateDeleter | - |
| 71 | { | - |
| 72 | static inline void cleanup(struct __res_state *pointer) | - |
| 73 | { | - |
| 74 | local_res_nclose(pointer); executed (the execution status of this line is deduced): local_res_nclose(pointer); | - |
| 75 | } executed: }Execution Count:41 | 41 |
| 76 | }; | - |
| 77 | | - |
| 78 | static void resolveLibrary() | - |
| 79 | { | - |
| 80 | QLibrary lib(QLatin1String("resolv")); executed (the execution status of this line is deduced): QLibrary lib(QLatin1String("resolv")); | - |
| 81 | if (!lib.load()) partially evaluated: !lib.load()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 82 | return; | 0 |
| 83 | | - |
| 84 | local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); executed (the execution status of this line is deduced): local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); | - |
| 85 | if (!local_dn_expand) partially evaluated: !local_dn_expand| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 86 | local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); never executed: local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); | 0 |
| 87 | | - |
| 88 | local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); executed (the execution status of this line is deduced): local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); | - |
| 89 | if (!local_res_nclose) partially evaluated: !local_res_nclose| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 90 | local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); never executed: local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); | 0 |
| 91 | if (!local_res_nclose) partially evaluated: !local_res_nclose| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 92 | local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); never executed: local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); | 0 |
| 93 | | - |
| 94 | local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); executed (the execution status of this line is deduced): local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); | - |
| 95 | if (!local_res_ninit) partially evaluated: !local_res_ninit| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 96 | local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); never executed: local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); | 0 |
| 97 | if (!local_res_ninit) partially evaluated: !local_res_ninit| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 98 | local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); never executed: local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); | 0 |
| 99 | | - |
| 100 | local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); executed (the execution status of this line is deduced): local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); | - |
| 101 | if (!local_res_nquery) partially evaluated: !local_res_nquery| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 102 | local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); never executed: local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); | 0 |
| 103 | if (!local_res_nquery) partially evaluated: !local_res_nquery| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 104 | local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); never executed: local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); | 0 |
| 105 | } executed: }Execution Count:2 | 2 |
| 106 | | - |
| 107 | void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) | - |
| 108 | { | - |
| 109 | // Load dn_expand, res_ninit and res_nquery on demand. | - |
| 110 | static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false); | - |
| 111 | if (!triedResolve.loadAcquire()) { evaluated: !triedResolve.loadAcquire()| yes Evaluation Count:2 | yes Evaluation Count:39 |
| 2-39 |
| 112 | QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_ninit)); executed (the execution status of this line is deduced): QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_ninit)); | - |
| 113 | if (!triedResolve.load()) { partially evaluated: !triedResolve.load()| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 114 | resolveLibrary(); executed (the execution status of this line is deduced): resolveLibrary(); | - |
| 115 | triedResolve.storeRelease(true); executed (the execution status of this line is deduced): triedResolve.storeRelease(true); | - |
| 116 | } executed: }Execution Count:2 | 2 |
| 117 | } executed: }Execution Count:2 | 2 |
| 118 | | - |
| 119 | // If dn_expand, res_ninit or res_nquery is missing, fail. | - |
| 120 | if (!local_dn_expand || !local_res_nclose || !local_res_ninit || !local_res_nquery) { partially evaluated: !local_dn_expand| no Evaluation Count:0 | yes Evaluation Count:41 |
partially evaluated: !local_res_nclose| no Evaluation Count:0 | yes Evaluation Count:41 |
partially evaluated: !local_res_ninit| no Evaluation Count:0 | yes Evaluation Count:41 |
partially evaluated: !local_res_nquery| no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-41 |
| 121 | reply->error = QDnsLookup::ResolverError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::ResolverError; | - |
| 122 | reply->errorString = tr("Resolver functions not found"); never executed (the execution status of this line is deduced): reply->errorString = tr("Resolver functions not found"); | - |
| 123 | return; | 0 |
| 124 | } | - |
| 125 | | - |
| 126 | // Initialize state. | - |
| 127 | struct __res_state state; executed (the execution status of this line is deduced): struct __res_state state; | - |
| 128 | memset(&state, 0, sizeof(state)); executed (the execution status of this line is deduced): memset(&state, 0, sizeof(state)); | - |
| 129 | if (local_res_ninit(&state) < 0) { partially evaluated: local_res_ninit(&state) < 0| no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-41 |
| 130 | reply->error = QDnsLookup::ResolverError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::ResolverError; | - |
| 131 | reply->errorString = tr("Resolver initialization failed"); never executed (the execution status of this line is deduced): reply->errorString = tr("Resolver initialization failed"); | - |
| 132 | return; | 0 |
| 133 | } | - |
| 134 | #ifdef QDNSLOOKUP_DEBUG | - |
| 135 | state.options |= RES_DEBUG; | - |
| 136 | #endif | - |
| 137 | QScopedPointer<struct __res_state, QDnsLookupStateDeleter> state_ptr(&state); executed (the execution status of this line is deduced): QScopedPointer<struct __res_state, QDnsLookupStateDeleter> state_ptr(&state); | - |
| 138 | | - |
| 139 | // Perform DNS query. | - |
| 140 | unsigned char response[PACKETSZ]; executed (the execution status of this line is deduced): unsigned char response[512]; | - |
| 141 | memset(response, 0, sizeof(response)); executed (the execution status of this line is deduced): memset(response, 0, sizeof(response)); | - |
| 142 | const int responseLength = local_res_nquery(&state, requestName, C_IN, requestType, response, sizeof(response)); executed (the execution status of this line is deduced): const int responseLength = local_res_nquery(&state, requestName, ns_c_in, requestType, response, sizeof(response)); | - |
| 143 | | - |
| 144 | // Check the response header. | - |
| 145 | HEADER *header = (HEADER*)response; executed (the execution status of this line is deduced): HEADER *header = (HEADER*)response; | - |
| 146 | const int answerCount = ntohs(header->ancount); never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8))); executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");Execution Count:41 partially evaluated: __builtin_constant_p (__x)| no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-41 |
| 147 | switch (header->rcode) { | - |
| 148 | case NOERROR: | - |
| 149 | break; executed: break;Execution Count:4 | 4 |
| 150 | case FORMERR: | - |
| 151 | reply->error = QDnsLookup::InvalidRequestError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidRequestError; | - |
| 152 | reply->errorString = tr("Server could not process query"); never executed (the execution status of this line is deduced): reply->errorString = tr("Server could not process query"); | - |
| 153 | return; | 0 |
| 154 | case SERVFAIL: | - |
| 155 | reply->error = QDnsLookup::ServerFailureError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::ServerFailureError; | - |
| 156 | reply->errorString = tr("Server failure"); never executed (the execution status of this line is deduced): reply->errorString = tr("Server failure"); | - |
| 157 | return; | 0 |
| 158 | case NXDOMAIN: | - |
| 159 | reply->error = QDnsLookup::NotFoundError; executed (the execution status of this line is deduced): reply->error = QDnsLookup::NotFoundError; | - |
| 160 | reply->errorString = tr("Non existent domain"); executed (the execution status of this line is deduced): reply->errorString = tr("Non existent domain"); | - |
| 161 | return; executed: return;Execution Count:37 | 37 |
| 162 | case REFUSED: | - |
| 163 | reply->error = QDnsLookup::ServerRefusedError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::ServerRefusedError; | - |
| 164 | reply->errorString = tr("Server refused to answer"); never executed (the execution status of this line is deduced): reply->errorString = tr("Server refused to answer"); | - |
| 165 | return; | 0 |
| 166 | default: | - |
| 167 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 168 | reply->errorString = tr("Invalid reply received"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid reply received"); | - |
| 169 | return; | 0 |
| 170 | } | - |
| 171 | | - |
| 172 | // Check the reply is valid. | - |
| 173 | if (responseLength < int(sizeof(HEADER))) { partially evaluated: responseLength < int(sizeof(HEADER))| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 174 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 175 | reply->errorString = tr("Invalid reply received"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid reply received"); | - |
| 176 | return; | 0 |
| 177 | } | - |
| 178 | | - |
| 179 | // Skip the query host, type (2 bytes) and class (2 bytes). | - |
| 180 | char host[PACKETSZ], answer[PACKETSZ]; executed (the execution status of this line is deduced): char host[512], answer[512]; | - |
| 181 | unsigned char *p = response + sizeof(HEADER); executed (the execution status of this line is deduced): unsigned char *p = response + sizeof(HEADER); | - |
| 182 | int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); executed (the execution status of this line is deduced): int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); | - |
| 183 | if (status < 0) { partially evaluated: status < 0| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 184 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 185 | reply->errorString = tr("Could not expand domain name"); never executed (the execution status of this line is deduced): reply->errorString = tr("Could not expand domain name"); | - |
| 186 | return; | 0 |
| 187 | } | - |
| 188 | p += status + 4; executed (the execution status of this line is deduced): p += status + 4; | - |
| 189 | | - |
| 190 | // Extract results. | - |
| 191 | int answerIndex = 0; executed (the execution status of this line is deduced): int answerIndex = 0; | - |
| 192 | while ((p < response + responseLength) && (answerIndex < answerCount)) { evaluated: (p < response + responseLength)| yes Evaluation Count:5 | yes Evaluation Count:4 |
partially evaluated: (answerIndex < answerCount)| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 193 | status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); | - |
| 194 | if (status < 0) { partially evaluated: status < 0| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 195 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 196 | reply->errorString = tr("Could not expand domain name"); never executed (the execution status of this line is deduced): reply->errorString = tr("Could not expand domain name"); | - |
| 197 | return; | 0 |
| 198 | } | - |
| 199 | const QString name = QUrl::fromAce(host); executed (the execution status of this line is deduced): const QString name = QUrl::fromAce(host); | - |
| 200 | | - |
| 201 | p += status; executed (the execution status of this line is deduced): p += status; | - |
| 202 | const quint16 type = (p[0] << 8) | p[1]; executed (the execution status of this line is deduced): const quint16 type = (p[0] << 8) | p[1]; | - |
| 203 | p += 2; // RR type executed (the execution status of this line is deduced): p += 2; | - |
| 204 | p += 2; // RR class executed (the execution status of this line is deduced): p += 2; | - |
| 205 | const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; executed (the execution status of this line is deduced): const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | - |
| 206 | p += 4; executed (the execution status of this line is deduced): p += 4; | - |
| 207 | const quint16 size = (p[0] << 8) | p[1]; executed (the execution status of this line is deduced): const quint16 size = (p[0] << 8) | p[1]; | - |
| 208 | p += 2; executed (the execution status of this line is deduced): p += 2; | - |
| 209 | | - |
| 210 | if (type == QDnsLookup::A) { partially evaluated: type == QDnsLookup::A| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 211 | if (size != 4) { never evaluated: size != 4 | 0 |
| 212 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 213 | reply->errorString = tr("Invalid IPv4 address record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid IPv4 address record"); | - |
| 214 | return; | 0 |
| 215 | } | - |
| 216 | const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; never executed (the execution status of this line is deduced): const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | - |
| 217 | QDnsHostAddressRecord record; never executed (the execution status of this line is deduced): QDnsHostAddressRecord record; | - |
| 218 | record.d->name = name; never executed (the execution status of this line is deduced): record.d->name = name; | - |
| 219 | record.d->timeToLive = ttl; never executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 220 | record.d->value = QHostAddress(addr); never executed (the execution status of this line is deduced): record.d->value = QHostAddress(addr); | - |
| 221 | reply->hostAddressRecords.append(record); never executed (the execution status of this line is deduced): reply->hostAddressRecords.append(record); | - |
| 222 | } else if (type == QDnsLookup::AAAA) { never executed: } partially evaluated: type == QDnsLookup::AAAA| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 223 | if (size != 16) { never evaluated: size != 16 | 0 |
| 224 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 225 | reply->errorString = tr("Invalid IPv6 address record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid IPv6 address record"); | - |
| 226 | return; | 0 |
| 227 | } | - |
| 228 | QDnsHostAddressRecord record; never executed (the execution status of this line is deduced): QDnsHostAddressRecord record; | - |
| 229 | record.d->name = name; never executed (the execution status of this line is deduced): record.d->name = name; | - |
| 230 | record.d->timeToLive = ttl; never executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 231 | record.d->value = QHostAddress(p); never executed (the execution status of this line is deduced): record.d->value = QHostAddress(p); | - |
| 232 | reply->hostAddressRecords.append(record); never executed (the execution status of this line is deduced): reply->hostAddressRecords.append(record); | - |
| 233 | } else if (type == QDnsLookup::CNAME) { never executed: } partially evaluated: type == QDnsLookup::CNAME| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 234 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); never executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - |
| 235 | if (status < 0) { never evaluated: status < 0 | 0 |
| 236 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 237 | reply->errorString = tr("Invalid canonical name record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid canonical name record"); | - |
| 238 | return; | 0 |
| 239 | } | - |
| 240 | QDnsDomainNameRecord record; never executed (the execution status of this line is deduced): QDnsDomainNameRecord record; | - |
| 241 | record.d->name = name; never executed (the execution status of this line is deduced): record.d->name = name; | - |
| 242 | record.d->timeToLive = ttl; never executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 243 | record.d->value = QUrl::fromAce(answer); never executed (the execution status of this line is deduced): record.d->value = QUrl::fromAce(answer); | - |
| 244 | reply->canonicalNameRecords.append(record); never executed (the execution status of this line is deduced): reply->canonicalNameRecords.append(record); | - |
| 245 | } else if (type == QDnsLookup::NS) { never executed: } evaluated: type == QDnsLookup::NS| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 0-3 |
| 246 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - |
| 247 | if (status < 0) { partially evaluated: status < 0| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 248 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 249 | reply->errorString = tr("Invalid name server record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid name server record"); | - |
| 250 | return; | 0 |
| 251 | } | - |
| 252 | QDnsDomainNameRecord record; executed (the execution status of this line is deduced): QDnsDomainNameRecord record; | - |
| 253 | record.d->name = name; executed (the execution status of this line is deduced): record.d->name = name; | - |
| 254 | record.d->timeToLive = ttl; executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 255 | record.d->value = QUrl::fromAce(answer); executed (the execution status of this line is deduced): record.d->value = QUrl::fromAce(answer); | - |
| 256 | reply->nameServerRecords.append(record); executed (the execution status of this line is deduced): reply->nameServerRecords.append(record); | - |
| 257 | } else if (type == QDnsLookup::PTR) { executed: }Execution Count:2 evaluated: type == QDnsLookup::PTR| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 258 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - |
| 259 | if (status < 0) { partially evaluated: status < 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 260 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 261 | reply->errorString = tr("Invalid pointer record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid pointer record"); | - |
| 262 | return; | 0 |
| 263 | } | - |
| 264 | QDnsDomainNameRecord record; executed (the execution status of this line is deduced): QDnsDomainNameRecord record; | - |
| 265 | record.d->name = name; executed (the execution status of this line is deduced): record.d->name = name; | - |
| 266 | record.d->timeToLive = ttl; executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 267 | record.d->value = QUrl::fromAce(answer); executed (the execution status of this line is deduced): record.d->value = QUrl::fromAce(answer); | - |
| 268 | reply->pointerRecords.append(record); executed (the execution status of this line is deduced): reply->pointerRecords.append(record); | - |
| 269 | } else if (type == QDnsLookup::MX) { executed: }Execution Count:1 evaluated: type == QDnsLookup::MX| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 270 | const quint16 preference = (p[0] << 8) | p[1]; executed (the execution status of this line is deduced): const quint16 preference = (p[0] << 8) | p[1]; | - |
| 271 | status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer)); executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer)); | - |
| 272 | if (status < 0) { partially evaluated: status < 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 273 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 274 | reply->errorString = tr("Invalid mail exchange record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid mail exchange record"); | - |
| 275 | return; | 0 |
| 276 | } | - |
| 277 | QDnsMailExchangeRecord record; executed (the execution status of this line is deduced): QDnsMailExchangeRecord record; | - |
| 278 | record.d->exchange = QUrl::fromAce(answer); executed (the execution status of this line is deduced): record.d->exchange = QUrl::fromAce(answer); | - |
| 279 | record.d->name = name; executed (the execution status of this line is deduced): record.d->name = name; | - |
| 280 | record.d->preference = preference; executed (the execution status of this line is deduced): record.d->preference = preference; | - |
| 281 | record.d->timeToLive = ttl; executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 282 | reply->mailExchangeRecords.append(record); executed (the execution status of this line is deduced): reply->mailExchangeRecords.append(record); | - |
| 283 | } else if (type == QDnsLookup::SRV) { executed: }Execution Count:1 partially evaluated: type == QDnsLookup::SRV| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 284 | const quint16 priority = (p[0] << 8) | p[1]; never executed (the execution status of this line is deduced): const quint16 priority = (p[0] << 8) | p[1]; | - |
| 285 | const quint16 weight = (p[2] << 8) | p[3]; never executed (the execution status of this line is deduced): const quint16 weight = (p[2] << 8) | p[3]; | - |
| 286 | const quint16 port = (p[4] << 8) | p[5]; never executed (the execution status of this line is deduced): const quint16 port = (p[4] << 8) | p[5]; | - |
| 287 | status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer)); never executed (the execution status of this line is deduced): status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer)); | - |
| 288 | if (status < 0) { never evaluated: status < 0 | 0 |
| 289 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 290 | reply->errorString = tr("Invalid service record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid service record"); | - |
| 291 | return; | 0 |
| 292 | } | - |
| 293 | QDnsServiceRecord record; never executed (the execution status of this line is deduced): QDnsServiceRecord record; | - |
| 294 | record.d->name = name; never executed (the execution status of this line is deduced): record.d->name = name; | - |
| 295 | record.d->target = QUrl::fromAce(answer); never executed (the execution status of this line is deduced): record.d->target = QUrl::fromAce(answer); | - |
| 296 | record.d->port = port; never executed (the execution status of this line is deduced): record.d->port = port; | - |
| 297 | record.d->priority = priority; never executed (the execution status of this line is deduced): record.d->priority = priority; | - |
| 298 | record.d->timeToLive = ttl; never executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 299 | record.d->weight = weight; never executed (the execution status of this line is deduced): record.d->weight = weight; | - |
| 300 | reply->serviceRecords.append(record); never executed (the execution status of this line is deduced): reply->serviceRecords.append(record); | - |
| 301 | } else if (type == QDnsLookup::TXT) { never executed: } partially evaluated: type == QDnsLookup::TXT| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 302 | unsigned char *txt = p; executed (the execution status of this line is deduced): unsigned char *txt = p; | - |
| 303 | QDnsTextRecord record; executed (the execution status of this line is deduced): QDnsTextRecord record; | - |
| 304 | record.d->name = name; executed (the execution status of this line is deduced): record.d->name = name; | - |
| 305 | record.d->timeToLive = ttl; executed (the execution status of this line is deduced): record.d->timeToLive = ttl; | - |
| 306 | while (txt < p + size) { evaluated: txt < p + size| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 307 | const unsigned char length = *txt; executed (the execution status of this line is deduced): const unsigned char length = *txt; | - |
| 308 | txt++; executed (the execution status of this line is deduced): txt++; | - |
| 309 | if (txt + length > p + size) { partially evaluated: txt + length > p + size| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 310 | reply->error = QDnsLookup::InvalidReplyError; never executed (the execution status of this line is deduced): reply->error = QDnsLookup::InvalidReplyError; | - |
| 311 | reply->errorString = tr("Invalid text record"); never executed (the execution status of this line is deduced): reply->errorString = tr("Invalid text record"); | - |
| 312 | return; | 0 |
| 313 | } | - |
| 314 | record.d->values << QByteArray((char*)txt, length); executed (the execution status of this line is deduced): record.d->values << QByteArray((char*)txt, length); | - |
| 315 | txt += length; executed (the execution status of this line is deduced): txt += length; | - |
| 316 | } executed: }Execution Count:1 | 1 |
| 317 | reply->textRecords.append(record); executed (the execution status of this line is deduced): reply->textRecords.append(record); | - |
| 318 | } executed: }Execution Count:1 | 1 |
| 319 | p += size; executed (the execution status of this line is deduced): p += size; | - |
| 320 | answerIndex++; executed (the execution status of this line is deduced): answerIndex++; | - |
| 321 | } executed: }Execution Count:5 | 5 |
| 322 | } executed: }Execution Count:4 | 4 |
| 323 | | - |
| 324 | #else | - |
| 325 | | - |
| 326 | void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) | - |
| 327 | { | - |
| 328 | Q_UNUSED(requestType) | - |
| 329 | Q_UNUSED(requestName) | - |
| 330 | reply->error = QDnsLookup::ResolverError; | - |
| 331 | reply->errorString = tr("Resolver library can't be loaded: No runtime library loading support"); | - |
| 332 | return; | - |
| 333 | } | - |
| 334 | | - |
| 335 | #endif /* ifndef QT_NO_LIBRARY */ | - |
| 336 | | - |
| 337 | QT_END_NAMESPACE | - |
| 338 | | - |
| | |