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