OpenCoverage

getrrsetbyname.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/openbsd-compat/getrrsetbyname.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9u_int16_t _getshort(register const u_char *);-
10u_int32_t _getlong(register const u_char *);-
11-
12-
13-
14-
15-
16-
17struct dns_query {-
18 char *name;-
19 u_int16_t type;-
20 u_int16_t class;-
21 struct dns_query *next;-
22};-
23-
24struct dns_rr {-
25 char *name;-
26 u_int16_t type;-
27 u_int16_t class;-
28 u_int16_t ttl;-
29 u_int16_t size;-
30 void *rdata;-
31 struct dns_rr *next;-
32};-
33-
34struct dns_response {-
35 HEADER header;-
36 struct dns_query *query;-
37 struct dns_rr *answer;-
38 struct dns_rr *authority;-
39 struct dns_rr *additional;-
40};-
41-
42static struct dns_response *parse_dns_response(const u_char *, int);-
43static struct dns_query *parse_dns_qsection(const u_char *, int,-
44 const u_char **, int);-
45static struct dns_rr *parse_dns_rrsection(const u_char *, int, const u_char **,-
46 int);-
47-
48static void free_dns_query(struct dns_query *);-
49static void free_dns_rr(struct dns_rr *);-
50static void free_dns_response(struct dns_response *);-
51-
52static int count_dns_rr(struct dns_rr *, u_int16_t, u_int16_t);-
53-
54int-
55getrrsetbyname(const char *hostname, unsigned int rdclass,-
56 unsigned int rdtype, unsigned int flags,-
57 struct rrsetinfo **res)-
58{-
59 struct __res_state *_resp = (&-
60 (*__res_state())-
61 );-
62 int result;-
63 struct rrsetinfo *rrset = -
64 ((void *)0)-
65 ;-
66 struct dns_response *response = -
67 ((void *)0)-
68 ;-
69 struct dns_rr *rr;-
70 struct rdatainfo *rdata;-
71 int length;-
72 unsigned int index_ans, index_sig;-
73 u_char answer[0xffff];-
74-
75-
76 if (rdclass > 0xffff
rdclass > 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
|| rdtype > 0xffff
rdtype > 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
77 result = 3;-
78 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
79 }-
80-
81-
82 if (rdclass == 0xff
rdclass == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
|| rdtype == 0xff
rdtype == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
83 result = 3;-
84 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
85 }-
86-
87-
88 if (flags
flagsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
89 result = 3;-
90 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
91 }-
92-
93-
94 if ((
(_resp->option...0000001 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
_resp->options &
(_resp->option...0000001 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
95 0x00000001
(_resp->option...0000001 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
96 ) == 0
(_resp->option...0000001 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
97 __res_init
__res_init () == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
98 () == -1
__res_init () == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
99 result = 2;-
100 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
101 }-
102-
103-
104-
105-
106-
107-
108-
109 if (_resp->options &
_resp->options & 0x00100000Description
TRUEnever evaluated
FALSEnever evaluated
0
110 0x00100000
_resp->options & 0x00100000Description
TRUEnever evaluated
FALSEnever evaluated
0
111 )-
112 _resp->options |=
never executed: _resp->options |= 0x00800000 ;
0
113 0x00800000
never executed: _resp->options |= 0x00800000 ;
0
114 ;
never executed: _resp->options |= 0x00800000 ;
0
115-
116-
117-
118 length = -
119 __res_query-
120 (hostname, (signed int) rdclass, (signed int) rdtype,-
121 answer, sizeof(answer));-
122 if (length < 0
length < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
123 switch(-
124 (*__h_errno_location ())-
125 ) {-
126 case
never executed: case 1 :
never executed: case 1 :
0
127 1
never executed: case 1 :
0
128 :
never executed: case 1 :
0
129 result = 4;-
130 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
131 case
never executed: case 4 :
never executed: case 4 :
0
132 4
never executed: case 4 :
0
133 :
never executed: case 4 :
0
134 result = 5;-
135 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
136 default
never executed: default:
:
never executed: default:
0
137 result = 2;-
138 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
139 }-
140 }-
141-
142-
143 response = parse_dns_response(answer, length);-
144 if (response ==
response == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
145 ((void *)0)
response == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
146 ) {-
147 result = 2;-
148 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
149 }-
150-
151 if (response->header.qdcount != 1
response->header.qdcount != 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
152 result = 2;-
153 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
154 }-
155-
156-
157 rrset = calloc(1, sizeof(struct rrsetinfo));-
158 if (rrset ==
rrset == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
159 ((void *)0)
rrset == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
160 ) {-
161 result = 1;-
162 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
163 }-
164 rrset->rri_rdclass = response->query->class;-
165 rrset->rri_rdtype = response->query->type;-
166 rrset->rri_ttl = response->answer->ttl;-
167 rrset->rri_nrdatas = response->header.ancount;-
168-
169-
170-
171 if (response->header.ad == 1
response->header.ad == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
172 rrset->rri_flags |= 1;
never executed: rrset->rri_flags |= 1;
0
173-
174-
175-
176 rrset->rri_name = -
177 (__extension__ (__builtin_constant_p (
__builtin_cons...answer->name )Description
TRUEnever evaluated
FALSEnever evaluated
0
178 response->answer->name
__builtin_cons...answer->name )Description
TRUEnever evaluated
FALSEnever evaluated
0
179 )
__builtin_cons...answer->name )Description
TRUEnever evaluated
FALSEnever evaluated
&& ((
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
size_t)(const void *)((
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
180 response->answer->name
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
181 ) + 1) - (size_t)(const void *)(
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
182 response->answer->name
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
183 ) == 1)
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
? (((const
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
char *) (
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
184 response->answer->name
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
185 ))[0] == '\0'
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (
0
186 response->answer->name-
187 ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
) __retval = (char *) memcpy (__retval,
never executed: __retval = (char *) memcpy (__retval, response->answer->name , __len);
0
188 response->answer->name
never executed: __retval = (char *) memcpy (__retval, response->answer->name , __len);
0
189 , __len);
never executed: __retval = (char *) memcpy (__retval, response->answer->name , __len);
__retval; })) : __strdup (
0
190 response->answer->name-
191 )))-
192 ;-
193 if (rrset->rri_name ==
rrset->rri_name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
194 ((void *)0)
rrset->rri_name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
195 ) {-
196 result = 1;-
197 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
198 }-
199-
200-
201 rrset->rri_nrdatas = count_dns_rr(response->answer, rrset->rri_rdclass,-
202 rrset->rri_rdtype);-
203 rrset->rri_nsigs = count_dns_rr(response->answer, rrset->rri_rdclass,-
204 46);-
205-
206-
207 rrset->rri_rdatas = calloc(rrset->rri_nrdatas,-
208 sizeof(struct rdatainfo));-
209 if (rrset->rri_rdatas ==
rrset->rri_rda...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
210 ((void *)0)
rrset->rri_rda...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
211 ) {-
212 result = 1;-
213 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
214 }-
215-
216-
217 if (rrset->rri_nsigs > 0
rrset->rri_nsigs > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
218 rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo));-
219 if (rrset->rri_sigs ==
rrset->rri_sigs == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
220 ((void *)0)
rrset->rri_sigs == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
221 ) {-
222 result = 1;-
223 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
224 }-
225 }
never executed: end of block
0
226-
227-
228 for (rr = response->answer, index_ans = 0, index_sig = 0;-
229 rr
rrDescription
TRUEnever evaluated
FALSEnever evaluated
; rr = rr->next) {
0
230-
231 rdata = -
232 ((void *)0)-
233 ;-
234-
235 if (rr->class == rrset->rri_rdclass
rr->class == r...t->rri_rdclassDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
236 rr->type == rrset->rri_rdtype
rr->type == rrset->rri_rdtypeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
237 rdata = &rrset->rri_rdatas[index_ans++];
never executed: rdata = &rrset->rri_rdatas[index_ans++];
0
238-
239 if (rr->class == rrset->rri_rdclass
rr->class == r...t->rri_rdclassDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
240 rr->type == 46
rr->type == 46Description
TRUEnever evaluated
FALSEnever evaluated
)
0
241 rdata = &rrset->rri_sigs[index_sig++];
never executed: rdata = &rrset->rri_sigs[index_sig++];
0
242-
243 if (rdata
rdataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
244 rdata->rdi_length = rr->size;-
245 rdata->rdi_data = malloc(rr->size);-
246-
247 if (rdata->rdi_data ==
rdata->rdi_data == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
248 ((void *)0)
rdata->rdi_data == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
249 ) {-
250 result = 1;-
251 goto
never executed: goto fail;
fail;
never executed: goto fail;
0
252 }-
253 memcpy(rdata->rdi_data, rr->rdata, rr->size);-
254 }
never executed: end of block
0
255 }
never executed: end of block
0
256 free_dns_response(response);-
257-
258 *res = rrset;-
259 return
never executed: return (0);
(0);
never executed: return (0);
0
260-
261fail:-
262 if (rrset !=
rrset != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
263 ((void *)0)
rrset != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
264 )-
265 freerrset(rrset);
never executed: freerrset(rrset);
0
266 if (response !=
response != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
267 ((void *)0)
response != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
268 )-
269 free_dns_response(response);
never executed: free_dns_response(response);
0
270 return
never executed: return (result);
(result);
never executed: return (result);
0
271}-
272-
273void-
274freerrset(struct rrsetinfo *rrset)-
275{-
276 u_int16_t i;-
277-
278 if (rrset ==
rrset == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
279 ((void *)0)
rrset == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
280 )-
281 return;
never executed: return;
0
282-
283 if (rrset->rri_rdatas
rrset->rri_rdatasDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
284 for (i = 0; i < rrset->rri_nrdatas
i < rrset->rri_nrdatasDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
285 if (rrset->rri_rdatas[i].rdi_data ==
rrset->rri_rda...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
286 ((void *)0)
rrset->rri_rda...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
287 )-
288 break;
never executed: break;
0
289 free(rrset->rri_rdatas[i].rdi_data);-
290 }
never executed: end of block
0
291 free(rrset->rri_rdatas);-
292 }
never executed: end of block
0
293-
294 if (rrset->rri_sigs
rrset->rri_sigsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
295 for (i = 0; i < rrset->rri_nsigs
i < rrset->rri_nsigsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
296 if (rrset->rri_sigs[i].rdi_data ==
rrset->rri_sig...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
297 ((void *)0)
rrset->rri_sig...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
298 )-
299 break;
never executed: break;
0
300 free(rrset->rri_sigs[i].rdi_data);-
301 }
never executed: end of block
0
302 free(rrset->rri_sigs);-
303 }
never executed: end of block
0
304-
305 if (rrset->rri_name
rrset->rri_nameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
306 free(rrset->rri_name);
never executed: free(rrset->rri_name);
0
307 free(rrset);-
308}
never executed: end of block
0
309-
310-
311-
312-
313static struct dns_response *-
314parse_dns_response(const u_char *answer, int size)-
315{-
316 struct dns_response *resp;-
317 const u_char *cp;-
318-
319-
320 resp = calloc(1, sizeof(*resp));-
321 if (resp ==
resp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
322 ((void *)0)
resp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
323 )-
324 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
325 ((void *)0)
never executed: return ( ((void *)0) );
0
326 );
never executed: return ( ((void *)0) );
0
327-
328-
329 cp = answer;-
330-
331-
332 memcpy(&resp->header, cp, -
333 12-
334 );-
335 cp += -
336 12-
337 ;-
338-
339-
340 resp->header.qdcount = -
341 (__extension__ ({ unsigned short int __v, __x = (unsigned short int) (-
342 resp->header.qdcount-
343 ); if (__builtin_constant_p (__x)
__builtin_constant_p (__x)Description
TRUEnever evaluated
FALSEnever evaluated
) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
else __asm__
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
__v; }))
0
344 ;-
345 resp->header.ancount = -
346 (__extension__ ({ unsigned short int __v, __x = (unsigned short int) (-
347 resp->header.ancount-
348 ); if (__builtin_constant_p (__x)
__builtin_constant_p (__x)Description
TRUEnever evaluated
FALSEnever evaluated
) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
else __asm__
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
__v; }))
0
349 ;-
350 resp->header.nscount = -
351 (__extension__ ({ unsigned short int __v, __x = (unsigned short int) (-
352 resp->header.nscount-
353 ); if (__builtin_constant_p (__x)
__builtin_constant_p (__x)Description
TRUEnever evaluated
FALSEnever evaluated
) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
else __asm__
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
__v; }))
0
354 ;-
355 resp->header.arcount = -
356 (__extension__ ({ unsigned short int __v, __x = (unsigned short int) (-
357 resp->header.arcount-
358 ); if (__builtin_constant_p (__x)
__builtin_constant_p (__x)Description
TRUEnever evaluated
FALSEnever evaluated
) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
else __asm__
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
__v; }))
0
359 ;-
360-
361-
362 if (resp->header.qdcount < 1
resp->header.qdcount < 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
363 free_dns_response(resp);-
364 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
365 ((void *)0)
never executed: return ( ((void *)0) );
0
366 );
never executed: return ( ((void *)0) );
0
367 }-
368-
369-
370 resp->query = parse_dns_qsection(answer, size, &cp,-
371 resp->header.qdcount);-
372 if (resp->header.qdcount
resp->header.qdcountDescription
TRUEnever evaluated
FALSEnever evaluated
&& resp->query ==
resp->query == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
373 ((void *)0)
resp->query == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
374 ) {-
375 free_dns_response(resp);-
376 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
377 ((void *)0)
never executed: return ( ((void *)0) );
0
378 );
never executed: return ( ((void *)0) );
0
379 }-
380-
381-
382 resp->answer = parse_dns_rrsection(answer, size, &cp,-
383 resp->header.ancount);-
384 if (resp->header.ancount
resp->header.ancountDescription
TRUEnever evaluated
FALSEnever evaluated
&& resp->answer ==
resp->answer == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
385 ((void *)0)
resp->answer == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
386 ) {-
387 free_dns_response(resp);-
388 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
389 ((void *)0)
never executed: return ( ((void *)0) );
0
390 );
never executed: return ( ((void *)0) );
0
391 }-
392-
393-
394 resp->authority = parse_dns_rrsection(answer, size, &cp,-
395 resp->header.nscount);-
396 if (resp->header.nscount
resp->header.nscountDescription
TRUEnever evaluated
FALSEnever evaluated
&& resp->authority ==
resp->authority == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
397 ((void *)0)
resp->authority == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
398 ) {-
399 free_dns_response(resp);-
400 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
401 ((void *)0)
never executed: return ( ((void *)0) );
0
402 );
never executed: return ( ((void *)0) );
0
403 }-
404-
405-
406 resp->additional = parse_dns_rrsection(answer, size, &cp,-
407 resp->header.arcount);-
408 if (resp->header.arcount
resp->header.arcountDescription
TRUEnever evaluated
FALSEnever evaluated
&& resp->additional ==
resp->addition...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
409 ((void *)0)
resp->addition...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
410 ) {-
411 free_dns_response(resp);-
412 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
413 ((void *)0)
never executed: return ( ((void *)0) );
0
414 );
never executed: return ( ((void *)0) );
0
415 }-
416-
417 return
never executed: return (resp);
(resp);
never executed: return (resp);
0
418}-
419-
420static struct dns_query *-
421parse_dns_qsection(const u_char *answer, int size, const u_char **cp, int count)-
422{-
423 struct dns_query *head, *curr, *prev;-
424 int i, length;-
425 char name[-
426 1025-
427 ];-
428-
429 for (i = 1, head = -
430 ((void *)0)-
431 , prev = -
432 ((void *)0)-
433 ; i <= count
i <= countDescription
TRUEnever evaluated
FALSEnever evaluated
; i++, prev = curr) {
0
434-
435-
436 curr = calloc(1, sizeof(struct dns_query));-
437 if (curr ==
curr == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
438 ((void *)0)
curr == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
439 ) {-
440 free_dns_query(head);-
441 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
442 ((void *)0)
never executed: return ( ((void *)0) );
0
443 );
never executed: return ( ((void *)0) );
0
444 }-
445 if (head ==
head == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
446 ((void *)0)
head == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
447 )-
448 head = curr;
never executed: head = curr;
0
449 if (prev !=
prev != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
450 ((void *)0)
prev != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
451 )-
452 prev->next = curr;
never executed: prev->next = curr;
0
453-
454-
455 length = -
456 __dn_expand-
457 (answer, answer + size, *cp, name,-
458 sizeof(name));-
459 if (length < 0
length < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
460 free_dns_query(head);-
461 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
462 ((void *)0)
never executed: return ( ((void *)0) );
0
463 );
never executed: return ( ((void *)0) );
0
464 }-
465 curr->name = -
466 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
0
467 name
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
0
468 )
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
&& ((
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
size_t)(const void *)((
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
469 name
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
470 ) + 1) - (size_t)(const void *)(
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
471 name
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
472 ) == 1)
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
? (((const
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
char *) (
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
473 name
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
474 ))[0] == '\0'
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (
0
475 name-
476 ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
) __retval = (char *) memcpy (__retval,
never executed: __retval = (char *) memcpy (__retval, name , __len);
0
477 name
never executed: __retval = (char *) memcpy (__retval, name , __len);
0
478 , __len);
never executed: __retval = (char *) memcpy (__retval, name , __len);
__retval; })) : __strdup (
0
479 name-
480 )))-
481 ;-
482 if (curr->name ==
curr->name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
483 ((void *)0)
curr->name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
484 ) {-
485 free_dns_query(head);-
486 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
487 ((void *)0)
never executed: return ( ((void *)0) );
0
488 );
never executed: return ( ((void *)0) );
0
489 }-
490 *cp += length;-
491-
492-
493 curr->type = _getshort(*cp);-
494 *cp += -
495 2-
496 ;-
497-
498-
499 curr->class = _getshort(*cp);-
500 *cp += -
501 2-
502 ;-
503 }
never executed: end of block
0
504-
505 return
never executed: return (head);
(head);
never executed: return (head);
0
506}-
507-
508static struct dns_rr *-
509parse_dns_rrsection(const u_char *answer, int size, const u_char **cp,-
510 int count)-
511{-
512 struct dns_rr *head, *curr, *prev;-
513 int i, length;-
514 char name[-
515 1025-
516 ];-
517-
518 for (i = 1, head = -
519 ((void *)0)-
520 , prev = -
521 ((void *)0)-
522 ; i <= count
i <= countDescription
TRUEnever evaluated
FALSEnever evaluated
; i++, prev = curr) {
0
523-
524-
525 curr = calloc(1, sizeof(struct dns_rr));-
526 if (curr ==
curr == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
527 ((void *)0)
curr == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
528 ) {-
529 free_dns_rr(head);-
530 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
531 ((void *)0)
never executed: return ( ((void *)0) );
0
532 );
never executed: return ( ((void *)0) );
0
533 }-
534 if (head ==
head == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
535 ((void *)0)
head == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
536 )-
537 head = curr;
never executed: head = curr;
0
538 if (prev !=
prev != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
539 ((void *)0)
prev != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
540 )-
541 prev->next = curr;
never executed: prev->next = curr;
0
542-
543-
544 length = -
545 __dn_expand-
546 (answer, answer + size, *cp, name,-
547 sizeof(name));-
548 if (length < 0
length < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
549 free_dns_rr(head);-
550 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
551 ((void *)0)
never executed: return ( ((void *)0) );
0
552 );
never executed: return ( ((void *)0) );
0
553 }-
554 curr->name = -
555 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
0
556 name
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
0
557 )
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
&& ((
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
size_t)(const void *)((
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
558 name
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
559 ) + 1) - (size_t)(const void *)(
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
560 name
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
561 ) == 1)
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
? (((const
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
char *) (
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
562 name
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
563 ))[0] == '\0'
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (
0
564 name-
565 ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
) __retval = (char *) memcpy (__retval,
never executed: __retval = (char *) memcpy (__retval, name , __len);
0
566 name
never executed: __retval = (char *) memcpy (__retval, name , __len);
0
567 , __len);
never executed: __retval = (char *) memcpy (__retval, name , __len);
__retval; })) : __strdup (
0
568 name-
569 )))-
570 ;-
571 if (curr->name ==
curr->name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
572 ((void *)0)
curr->name == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
573 ) {-
574 free_dns_rr(head);-
575 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
576 ((void *)0)
never executed: return ( ((void *)0) );
0
577 );
never executed: return ( ((void *)0) );
0
578 }-
579 *cp += length;-
580-
581-
582 curr->type = _getshort(*cp);-
583 *cp += -
584 2-
585 ;-
586-
587-
588 curr->class = _getshort(*cp);-
589 *cp += -
590 2-
591 ;-
592-
593-
594 curr->ttl = _getlong(*cp);-
595 *cp += -
596 4-
597 ;-
598-
599-
600 curr->size = _getshort(*cp);-
601 *cp += -
602 2-
603 ;-
604-
605-
606 curr->rdata = malloc(curr->size);-
607 if (curr->rdata ==
curr->rdata == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
608 ((void *)0)
curr->rdata == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
609 ) {-
610 free_dns_rr(head);-
611 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
612 ((void *)0)
never executed: return ( ((void *)0) );
0
613 );
never executed: return ( ((void *)0) );
0
614 }-
615 memcpy(curr->rdata, *cp, curr->size);-
616 *cp += curr->size;-
617 }
never executed: end of block
0
618-
619 return
never executed: return (head);
(head);
never executed: return (head);
0
620}-
621-
622static void-
623free_dns_query(struct dns_query *p)-
624{-
625 if (p ==
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
626 ((void *)0)
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
627 )-
628 return;
never executed: return;
0
629-
630 if (p->name
p->nameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
631 free(p->name);
never executed: free(p->name);
0
632 free_dns_query(p->next);-
633 free(p);-
634}
never executed: end of block
0
635-
636static void-
637free_dns_rr(struct dns_rr *p)-
638{-
639 if (p ==
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
640 ((void *)0)
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
641 )-
642 return;
never executed: return;
0
643-
644 if (p->name
p->nameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
645 free(p->name);
never executed: free(p->name);
0
646 if (p->rdata
p->rdataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
647 free(p->rdata);
never executed: free(p->rdata);
0
648 free_dns_rr(p->next);-
649 free(p);-
650}
never executed: end of block
0
651-
652static void-
653free_dns_response(struct dns_response *p)-
654{-
655 if (p ==
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
656 ((void *)0)
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
657 )-
658 return;
never executed: return;
0
659-
660 free_dns_query(p->query);-
661 free_dns_rr(p->answer);-
662 free_dns_rr(p->authority);-
663 free_dns_rr(p->additional);-
664 free(p);-
665}
never executed: end of block
0
666-
667static int-
668count_dns_rr(struct dns_rr *p, u_int16_t class, u_int16_t type)-
669{-
670 int n = 0;-
671-
672 while(p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
673 if (p->class == class
p->class == classDescription
TRUEnever evaluated
FALSEnever evaluated
&& p->type == type
p->type == typeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
674 n++;
never executed: n++;
0
675 p = p->next;-
676 }
never executed: end of block
0
677-
678 return
never executed: return (n);
(n);
never executed: return (n);
0
679}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2