| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qdnslookup_unix.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); | - | ||||||||||||||||||||||||
| 20 | static dn_expand_proto local_dn_expand = 0; | - | ||||||||||||||||||||||||
| 21 | typedef void (*res_nclose_proto)(res_state); | - | ||||||||||||||||||||||||
| 22 | static res_nclose_proto local_res_nclose = 0; | - | ||||||||||||||||||||||||
| 23 | typedef int (*res_ninit_proto)(res_state); | - | ||||||||||||||||||||||||
| 24 | static res_ninit_proto local_res_ninit = 0; | - | ||||||||||||||||||||||||
| 25 | typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); | - | ||||||||||||||||||||||||
| 26 | static res_nquery_proto local_res_nquery = 0; | - | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | struct QDnsLookupStateDeleter | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | static inline void cleanup(struct __res_state *pointer) | - | ||||||||||||||||||||||||
| 33 | { | - | ||||||||||||||||||||||||
| 34 | local_res_nclose(pointer); | - | ||||||||||||||||||||||||
| 35 | } | - | ||||||||||||||||||||||||
| 36 | }; | - | ||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | static bool resolveLibraryInternal() | - | ||||||||||||||||||||||||
| 39 | { | - | ||||||||||||||||||||||||
| 40 | QLibrary lib; | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | lib.setFileName(([]() -> QString { enum { Size = sizeof(u"" "libresolv.so.2")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "libresolv.so.2" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | - | ||||||||||||||||||||||||
| 43 | if (!lib.load()) | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||
| 46 | lib.setFileName(QLatin1String("resolv")); | - | ||||||||||||||||||||||||
| 47 | if (!lib.load()) | - | ||||||||||||||||||||||||
| 48 | return false; | - | ||||||||||||||||||||||||
| 49 | } | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); | - | ||||||||||||||||||||||||
| 52 | if (!local_dn_expand) | - | ||||||||||||||||||||||||
| 53 | local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); | - | ||||||||||||||||||||||||
| 56 | if (!local_res_nclose) | - | ||||||||||||||||||||||||
| 57 | local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); | - | ||||||||||||||||||||||||
| 58 | if (!local_res_nclose) | - | ||||||||||||||||||||||||
| 59 | local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); | - | ||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); | - | ||||||||||||||||||||||||
| 62 | if (!local_res_ninit) | - | ||||||||||||||||||||||||
| 63 | local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); | - | ||||||||||||||||||||||||
| 64 | if (!local_res_ninit) | - | ||||||||||||||||||||||||
| 65 | local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); | - | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); | - | ||||||||||||||||||||||||
| 68 | if (!local_res_nquery) | - | ||||||||||||||||||||||||
| 69 | local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); | - | ||||||||||||||||||||||||
| 70 | if (!local_res_nquery) | - | ||||||||||||||||||||||||
| 71 | local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | return true; | - | ||||||||||||||||||||||||
| 74 | } | - | ||||||||||||||||||||||||
| 75 | namespace { namespace Q_QGS_resolveLibrary { typedef bool Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (resolveLibraryInternal()))) : value (resolveLibraryInternal()) { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<bool, Q_QGS_resolveLibrary::innerFunction, Q_QGS_resolveLibrary::guard> resolveLibrary; | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply) | - | ||||||||||||||||||||||||
| 78 | { | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | resolveLibrary(); | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | if (!local_dn_expand
| 0-84 | ||||||||||||||||||||||||
| 84 | reply->error = QDnsLookup::ResolverError; | - | ||||||||||||||||||||||||
| 85 | reply->errorString = tr("Resolver functions not found"); | - | ||||||||||||||||||||||||
| 86 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 87 | } | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | struct __res_state state; | - | ||||||||||||||||||||||||
| 91 | memset(&state, 0, sizeof(state)); | - | ||||||||||||||||||||||||
| 92 | if (local_res_ninit(&state) < 0
| 0-84 | ||||||||||||||||||||||||
| 93 | reply->error = QDnsLookup::ResolverError; | - | ||||||||||||||||||||||||
| 94 | reply->errorString = tr("Resolver initialization failed"); | - | ||||||||||||||||||||||||
| 95 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | if (!nameserver.isNull()
| 0-84 | ||||||||||||||||||||||||
| 100 | if (nameserver.protocol() == QAbstractSocket::IPv4Protocol
| 0 | ||||||||||||||||||||||||
| 101 | state.nsaddr_list[0].sin_addr.s_addr = htonl(nameserver.toIPv4Address()); | - | ||||||||||||||||||||||||
| 102 | state.nscount = 1; | - | ||||||||||||||||||||||||
| 103 | } never executed: else if (nameserver.protocol() == QAbstractSocket::IPv6Protocolend of block
| 0 | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | struct sockaddr_in6 *ns; | - | ||||||||||||||||||||||||
| 106 | ns = state._u._ext.nsaddrs[0]; | - | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | if (!ns
| 0 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | ns = (struct sockaddr_in6*) calloc(1, sizeof(struct sockaddr_in6)); | - | ||||||||||||||||||||||||
| 112 | do {if(!(ns)
never executed: } while (0);qt_check_pointer(__FILE__,159); | 0 | ||||||||||||||||||||||||
| 113 | state._u._ext.nsaddrs[0] = ns; | - | ||||||||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | state._u._ext.nsmap[0] = 3 + 1; | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | state._u._ext.nscount6 = 1; | - | ||||||||||||||||||||||||
| 121 | ns->sin6_family = 10; | - | ||||||||||||||||||||||||
| 122 | ns->sin6_port = htons(53); | - | ||||||||||||||||||||||||
| 123 | SetSALen::set(ns, sizeof(*ns)); | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | Q_IPV6ADDR ipv6Address = nameserver.toIPv6Address(); | - | ||||||||||||||||||||||||
| 126 | for (int i=0; i<16
| 0 | ||||||||||||||||||||||||
| 127 | ns->sin6_addr.__in6_u.__u6_addr8[i] = ipv6Address[i]; | - | ||||||||||||||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | QScopedPointer<struct __res_state, QDnsLookupStateDeleter> state_ptr(&state); | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | unsigned char response[512]; | - | ||||||||||||||||||||||||
| 144 | memset(response, 0, sizeof(response)); | - | ||||||||||||||||||||||||
| 145 | const int responseLength = local_res_nquery(&state, requestName, ns_c_in, requestType, response, sizeof(response)); | - | ||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | HEADER *header = (HEADER*)response; | - | ||||||||||||||||||||||||
| 149 | const int answerCount = ntohs(header->ancount); | - | ||||||||||||||||||||||||
| 150 | switch (header->rcode) { | - | ||||||||||||||||||||||||
| 151 | case executed 58 times by 2 tests: ns_r_noerror:case ns_r_noerror:Executed by:
executed 58 times by 2 tests: case ns_r_noerror:Executed by:
| 58 | ||||||||||||||||||||||||
| 152 | break; executed 58 times by 2 tests: break;Executed by:
| 58 | ||||||||||||||||||||||||
| 153 | case never executed: ns_r_formerr:case ns_r_formerr:never executed: case ns_r_formerr: | 0 | ||||||||||||||||||||||||
| 154 | reply->error = QDnsLookup::InvalidRequestError; | - | ||||||||||||||||||||||||
| 155 | reply->errorString = tr("Server could not process query"); | - | ||||||||||||||||||||||||
| 156 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 157 | case never executed: ns_r_servfail:case ns_r_servfail:never executed: case ns_r_servfail: | 0 | ||||||||||||||||||||||||
| 158 | reply->error = QDnsLookup::ServerFailureError; | - | ||||||||||||||||||||||||
| 159 | reply->errorString = tr("Server failure"); | - | ||||||||||||||||||||||||
| 160 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 161 | case executed 26 times by 2 tests: ns_r_nxdomain:case ns_r_nxdomain:Executed by:
executed 26 times by 2 tests: case ns_r_nxdomain:Executed by:
| 26 | ||||||||||||||||||||||||
| 162 | reply->error = QDnsLookup::NotFoundError; | - | ||||||||||||||||||||||||
| 163 | reply->errorString = tr("Non existent domain"); | - | ||||||||||||||||||||||||
| 164 | return; executed 26 times by 2 tests: return;Executed by:
| 26 | ||||||||||||||||||||||||
| 165 | case never executed: ns_r_refused:case ns_r_refused:never executed: case ns_r_refused: | 0 | ||||||||||||||||||||||||
| 166 | reply->error = QDnsLookup::ServerRefusedError; | - | ||||||||||||||||||||||||
| 167 | reply->errorString = tr("Server refused to answer"); | - | ||||||||||||||||||||||||
| 168 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 169 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 170 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 171 | reply->errorString = tr("Invalid reply received"); | - | ||||||||||||||||||||||||
| 172 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | if (responseLength < int(sizeof(HEADER))
| 0-58 | ||||||||||||||||||||||||
| 177 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 178 | reply->errorString = tr("Invalid reply received"); | - | ||||||||||||||||||||||||
| 179 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 180 | } | - | ||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | char host[512], answer[512]; | - | ||||||||||||||||||||||||
| 184 | unsigned char *p = response + sizeof(HEADER); | - | ||||||||||||||||||||||||
| 185 | int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); | - | ||||||||||||||||||||||||
| 186 | if (status < 0
| 0-58 | ||||||||||||||||||||||||
| 187 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 188 | reply->errorString = tr("Could not expand domain name"); | - | ||||||||||||||||||||||||
| 189 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||
| 191 | p += status + 4; | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||
| 194 | int answerIndex = 0; | - | ||||||||||||||||||||||||
| 195 | while ((
| 6-100 | ||||||||||||||||||||||||
| 196 | status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); | - | ||||||||||||||||||||||||
| 197 | if (status < 0
| 0-94 | ||||||||||||||||||||||||
| 198 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 199 | reply->errorString = tr("Could not expand domain name"); | - | ||||||||||||||||||||||||
| 200 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||
| 202 | const QString name = QUrl::fromAce(host); | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | p += status; | - | ||||||||||||||||||||||||
| 205 | const quint16 type = (p[0] << 8) | p[1]; | - | ||||||||||||||||||||||||
| 206 | p += 2; | - | ||||||||||||||||||||||||
| 207 | p += 2; | - | ||||||||||||||||||||||||
| 208 | const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | - | ||||||||||||||||||||||||
| 209 | p += 4; | - | ||||||||||||||||||||||||
| 210 | const quint16 size = (p[0] << 8) | p[1]; | - | ||||||||||||||||||||||||
| 211 | p += 2; | - | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | if (type == QDnsLookup::A
| 32-62 | ||||||||||||||||||||||||
| 214 | if (size != 4
| 0-32 | ||||||||||||||||||||||||
| 215 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 216 | reply->errorString = tr("Invalid IPv4 address record"); | - | ||||||||||||||||||||||||
| 217 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||
| 219 | const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | - | ||||||||||||||||||||||||
| 220 | QDnsHostAddressRecord record; | - | ||||||||||||||||||||||||
| 221 | record.d->name = name; | - | ||||||||||||||||||||||||
| 222 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 223 | record.d->value = QHostAddress(addr); | - | ||||||||||||||||||||||||
| 224 | reply->hostAddressRecords.append(record); | - | ||||||||||||||||||||||||
| 225 | } executed 32 times by 2 tests: else if (type == QDnsLookup::AAAAend of blockExecuted by:
| 18-44 | ||||||||||||||||||||||||
| 226 | if (size != 16
| 0-18 | ||||||||||||||||||||||||
| 227 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 228 | reply->errorString = tr("Invalid IPv6 address record"); | - | ||||||||||||||||||||||||
| 229 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 230 | } | - | ||||||||||||||||||||||||
| 231 | QDnsHostAddressRecord record; | - | ||||||||||||||||||||||||
| 232 | record.d->name = name; | - | ||||||||||||||||||||||||
| 233 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 234 | record.d->value = QHostAddress(p); | - | ||||||||||||||||||||||||
| 235 | reply->hostAddressRecords.append(record); | - | ||||||||||||||||||||||||
| 236 | } executed 18 times by 1 test: else if (type == QDnsLookup::CNAMEend of blockExecuted by:
| 0-44 | ||||||||||||||||||||||||
| 237 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - | ||||||||||||||||||||||||
| 238 | if (status < 0
| 0 | ||||||||||||||||||||||||
| 239 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 240 | reply->errorString = tr("Invalid canonical name record"); | - | ||||||||||||||||||||||||
| 241 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 242 | } | - | ||||||||||||||||||||||||
| 243 | QDnsDomainNameRecord record; | - | ||||||||||||||||||||||||
| 244 | record.d->name = name; | - | ||||||||||||||||||||||||
| 245 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 246 | record.d->value = QUrl::fromAce(answer); | - | ||||||||||||||||||||||||
| 247 | reply->canonicalNameRecords.append(record); | - | ||||||||||||||||||||||||
| 248 | } never executed: else if (type == QDnsLookup::NSend of block
| 0-38 | ||||||||||||||||||||||||
| 249 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - | ||||||||||||||||||||||||
| 250 | if (status < 0
| 0-6 | ||||||||||||||||||||||||
| 251 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 252 | reply->errorString = tr("Invalid name server record"); | - | ||||||||||||||||||||||||
| 253 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||
| 255 | QDnsDomainNameRecord record; | - | ||||||||||||||||||||||||
| 256 | record.d->name = name; | - | ||||||||||||||||||||||||
| 257 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 258 | record.d->value = QUrl::fromAce(answer); | - | ||||||||||||||||||||||||
| 259 | reply->nameServerRecords.append(record); | - | ||||||||||||||||||||||||
| 260 | } executed 6 times by 1 test: else if (type == QDnsLookup::PTRend of blockExecuted by:
| 0-38 | ||||||||||||||||||||||||
| 261 | status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); | - | ||||||||||||||||||||||||
| 262 | if (status < 0
| 0 | ||||||||||||||||||||||||
| 263 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 264 | reply->errorString = tr("Invalid pointer record"); | - | ||||||||||||||||||||||||
| 265 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 266 | } | - | ||||||||||||||||||||||||
| 267 | QDnsDomainNameRecord record; | - | ||||||||||||||||||||||||
| 268 | record.d->name = name; | - | ||||||||||||||||||||||||
| 269 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 270 | record.d->value = QUrl::fromAce(answer); | - | ||||||||||||||||||||||||
| 271 | reply->pointerRecords.append(record); | - | ||||||||||||||||||||||||
| 272 | } never executed: else if (type == QDnsLookup::MXend of block
| 0-26 | ||||||||||||||||||||||||
| 273 | const quint16 preference = (p[0] << 8) | p[1]; | - | ||||||||||||||||||||||||
| 274 | status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer)); | - | ||||||||||||||||||||||||
| 275 | if (status < 0
| 0-12 | ||||||||||||||||||||||||
| 276 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 277 | reply->errorString = tr("Invalid mail exchange record"); | - | ||||||||||||||||||||||||
| 278 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 279 | } | - | ||||||||||||||||||||||||
| 280 | QDnsMailExchangeRecord record; | - | ||||||||||||||||||||||||
| 281 | record.d->exchange = QUrl::fromAce(answer); | - | ||||||||||||||||||||||||
| 282 | record.d->name = name; | - | ||||||||||||||||||||||||
| 283 | record.d->preference = preference; | - | ||||||||||||||||||||||||
| 284 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 285 | reply->mailExchangeRecords.append(record); | - | ||||||||||||||||||||||||
| 286 | } executed 12 times by 1 test: else if (type == QDnsLookup::SRVend of blockExecuted by:
| 8-18 | ||||||||||||||||||||||||
| 287 | const quint16 priority = (p[0] << 8) | p[1]; | - | ||||||||||||||||||||||||
| 288 | const quint16 weight = (p[2] << 8) | p[3]; | - | ||||||||||||||||||||||||
| 289 | const quint16 port = (p[4] << 8) | p[5]; | - | ||||||||||||||||||||||||
| 290 | status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer)); | - | ||||||||||||||||||||||||
| 291 | if (status < 0
| 0-18 | ||||||||||||||||||||||||
| 292 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 293 | reply->errorString = tr("Invalid service record"); | - | ||||||||||||||||||||||||
| 294 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 295 | } | - | ||||||||||||||||||||||||
| 296 | QDnsServiceRecord record; | - | ||||||||||||||||||||||||
| 297 | record.d->name = name; | - | ||||||||||||||||||||||||
| 298 | record.d->target = QUrl::fromAce(answer); | - | ||||||||||||||||||||||||
| 299 | record.d->port = port; | - | ||||||||||||||||||||||||
| 300 | record.d->priority = priority; | - | ||||||||||||||||||||||||
| 301 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 302 | record.d->weight = weight; | - | ||||||||||||||||||||||||
| 303 | reply->serviceRecords.append(record); | - | ||||||||||||||||||||||||
| 304 | } executed 18 times by 1 test: else if (type == QDnsLookup::TXTend of blockExecuted by:
| 0-18 | ||||||||||||||||||||||||
| 305 | unsigned char *txt = p; | - | ||||||||||||||||||||||||
| 306 | QDnsTextRecord record; | - | ||||||||||||||||||||||||
| 307 | record.d->name = name; | - | ||||||||||||||||||||||||
| 308 | record.d->timeToLive = ttl; | - | ||||||||||||||||||||||||
| 309 | while (txt < p + size
| 8-10 | ||||||||||||||||||||||||
| 310 | const unsigned char length = *txt; | - | ||||||||||||||||||||||||
| 311 | txt++; | - | ||||||||||||||||||||||||
| 312 | if (txt + length > p + size
| 0-10 | ||||||||||||||||||||||||
| 313 | reply->error = QDnsLookup::InvalidReplyError; | - | ||||||||||||||||||||||||
| 314 | reply->errorString = tr("Invalid text record"); | - | ||||||||||||||||||||||||
| 315 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | record.d->values << QByteArray((char*)txt, length); | - | ||||||||||||||||||||||||
| 318 | txt += length; | - | ||||||||||||||||||||||||
| 319 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 320 | reply->textRecords.append(record); | - | ||||||||||||||||||||||||
| 321 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 322 | p += size; | - | ||||||||||||||||||||||||
| 323 | answerIndex++; | - | ||||||||||||||||||||||||
| 324 | } executed 94 times by 2 tests: end of blockExecuted by:
| 94 | ||||||||||||||||||||||||
| 325 | } executed 58 times by 2 tests: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |