Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | int | - |
10 | bindresvport_sa(int sd, struct sockaddr *sa) | - |
11 | { | - |
12 | int error, af; | - |
13 | struct sockaddr_storage myaddr; | - |
14 | struct sockaddr_in *in; | - |
15 | struct sockaddr_in6 *in6; | - |
16 | u_int16_t *portp; | - |
17 | u_int16_t port; | - |
18 | socklen_t salen; | - |
19 | int i; | - |
20 | | - |
21 | if (sa == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
22 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
23 | ) { | - |
24 | memset(&myaddr, 0, sizeof(myaddr)); | - |
25 | sa = (struct sockaddr *)&myaddr; | - |
26 | salen = sizeof(myaddr); | - |
27 | | - |
28 | if (getsockname(sd, sa, &salen) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
29 | return never executed: return -1; -1;never executed: return -1; | 0 |
30 | | - |
31 | af = sa->sa_family; | - |
32 | memset(&myaddr, 0, salen); | - |
33 | } never executed: end of block else | 0 |
34 | af = sa->sa_family; never executed: af = sa->sa_family; | 0 |
35 | | - |
36 | if (af == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
37 | 2TRUE | never evaluated | FALSE | never evaluated |
| 0 |
38 | ) { | - |
39 | in = (struct sockaddr_in *)sa; | - |
40 | salen = sizeof(struct sockaddr_in); | - |
41 | portp = &in->sin_port; | - |
42 | } never executed: end of block else if (af == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
43 | 10TRUE | never evaluated | FALSE | never evaluated |
| 0 |
44 | ) { | - |
45 | in6 = (struct sockaddr_in6 *)sa; | - |
46 | salen = sizeof(struct sockaddr_in6); | - |
47 | portp = &in6->sin6_port; | - |
48 | } never executed: end of block else { | 0 |
49 | | - |
50 | (*__errno_location ()) | - |
51 | = | - |
52 | 96 | - |
53 | ; | - |
54 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
55 | } | - |
56 | sa->sa_family = af; | - |
57 | | - |
58 | port = | - |
59 | (__extension__ ({ unsigned short int __v, __x = (unsigned short int) ( | - |
60 | *portp | - |
61 | ); if (__builtin_constant_p (__x)TRUE | never evaluated | FALSE | never 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 |
62 | ; | - |
63 | if (port == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
64 | port = arc4random_uniform((( never executed: port = arc4random_uniform((( 1024 - 1) - 600 + 1)) + 600; | 0 |
65 | 1024 never executed: port = arc4random_uniform((( 1024 - 1) - 600 + 1)) + 600; | 0 |
66 | - 1) - 600 + 1)) + 600; never executed: port = arc4random_uniform((( 1024 - 1) - 600 + 1)) + 600; | 0 |
67 | | - |
68 | | - |
69 | error = -1; | - |
70 | | - |
71 | for(i = 0; i < ((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
72 | 1024 TRUE | never evaluated | FALSE | never evaluated |
| 0 |
73 | - 1) - 600 + 1)TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
74 | *portp = | - |
75 | (__extension__ ({ unsigned short int __v, __x = (unsigned short int) ( | - |
76 | port | - |
77 | ); if (__builtin_constant_p (__x)TRUE | never evaluated | FALSE | never 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 |
78 | ; | - |
79 | | - |
80 | error = bind(sd, sa, salen); | - |
81 | | - |
82 | | - |
83 | if (error == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
84 | break; never executed: break; | 0 |
85 | | - |
86 | | - |
87 | if ((TRUE | never evaluated | FALSE | never evaluated |
error < 0)TRUE | never evaluated | FALSE | never evaluated |
&& !((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
88 | (*__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
89 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | 98TRUE | never evaluated | FALSE | never evaluated |
| 0 |
91 | )TRUE | never evaluated | FALSE | never evaluated |
|| (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
92 | (*__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
94 | 22TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | )TRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
96 | break; never executed: break; | 0 |
97 | | - |
98 | port++; | - |
99 | if (port > (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
100 | 1024 TRUE | never evaluated | FALSE | never evaluated |
| 0 |
101 | - 1)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
102 | port = 600; never executed: port = 600; | 0 |
103 | } never executed: end of block | 0 |
104 | | - |
105 | return never executed: return (error); (error);never executed: return (error); | 0 |
106 | } | - |
| | |