Lines 1-6
Link Here
|
1 |
--- dht.c 2011-07-25 17:59:36.000000000 -0400 |
1 |
--- dht.c 2018-02-09 16:44:37.000000000 -0500 |
2 |
+++ dht.c 2012-07-28 16:21:07.000000000 -0400 |
2 |
+++ dht.c 2018-12-02 18:00:11.873381000 -0500 |
3 |
@@ -356,5 +356,5 @@ |
3 |
@@ -365,5 +365,5 @@ |
4 |
switch(sa->sa_family) { |
4 |
switch(sa->sa_family) { |
5 |
case AF_INET: { |
5 |
case AF_INET: { |
6 |
- struct sockaddr_in *sin = (struct sockaddr_in*)sa; |
6 |
- struct sockaddr_in *sin = (struct sockaddr_in*)sa; |
Lines 7-13
Link Here
|
7 |
+ const struct sockaddr_in *sin = (const struct sockaddr_in*)sa; |
7 |
+ const struct sockaddr_in *sin = (const struct sockaddr_in*)sa; |
8 |
const unsigned char *address = (const unsigned char*)&sin->sin_addr; |
8 |
const unsigned char *address = (const unsigned char*)&sin->sin_addr; |
9 |
return sin->sin_port == 0 || |
9 |
return sin->sin_port == 0 || |
10 |
@@ -364,5 +364,5 @@ |
10 |
@@ -373,5 +373,5 @@ |
11 |
} |
11 |
} |
12 |
case AF_INET6: { |
12 |
case AF_INET6: { |
13 |
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa; |
13 |
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa; |
Lines 14-20
Link Here
|
14 |
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa; |
14 |
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa; |
15 |
const unsigned char *address = (const unsigned char*)&sin6->sin6_addr; |
15 |
const unsigned char *address = (const unsigned char*)&sin6->sin6_addr; |
16 |
return sin6->sin6_port == 0 || |
16 |
return sin6->sin6_port == 0 || |
17 |
@@ -1281,13 +1281,13 @@ |
17 |
@@ -1427,13 +1427,13 @@ |
18 |
int i, len; |
18 |
int i, len; |
19 |
struct storage *st; |
19 |
struct storage *st; |
20 |
- unsigned char *ip; |
20 |
- unsigned char *ip; |
Lines 33-39
Link Here
|
33 |
+ ip = (const unsigned char*)&sin6->sin6_addr; |
33 |
+ ip = (const unsigned char*)&sin6->sin6_addr; |
34 |
len = 16; |
34 |
len = 16; |
35 |
} else { |
35 |
} else { |
36 |
@@ -1406,15 +1406,15 @@ |
36 |
@@ -1552,15 +1552,15 @@ |
37 |
make_token(const struct sockaddr *sa, int old, unsigned char *token_return) |
37 |
make_token(const struct sockaddr *sa, int old, unsigned char *token_return) |
38 |
{ |
38 |
{ |
39 |
- void *ip; |
39 |
- void *ip; |
Lines 52-58
Link Here
|
52 |
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa; |
52 |
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa; |
53 |
ip = &sin6->sin6_addr; |
53 |
ip = &sin6->sin6_addr; |
54 |
iplen = 16; |
54 |
iplen = 16; |
55 |
@@ -1892,5 +1892,5 @@ |
55 |
@@ -2038,5 +2038,5 @@ |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
- if(((char*)buf)[buflen] != '\0') { |
58 |
- if(((char*)buf)[buflen] != '\0') { |
Lines 59-65
Link Here
|
59 |
+ if(((const char*)buf)[buflen] != '\0') { |
59 |
+ if(((const char*)buf)[buflen] != '\0') { |
60 |
debugf("Unterminated message.\n"); |
60 |
debugf("Unterminated message.\n"); |
61 |
errno = EINVAL; |
61 |
errno = EINVAL; |
62 |
@@ -2743,5 +2743,5 @@ |
62 |
@@ -2905,5 +2905,5 @@ |
63 |
|
63 |
|
64 |
#define CHECK(ptr, len) \ |
64 |
#define CHECK(ptr, len) \ |
65 |
- if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow; |
65 |
- if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow; |
Lines 66-72
Link Here
|
66 |
+ if(((const unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow; |
66 |
+ if(((const unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow; |
67 |
|
67 |
|
68 |
if(tid_return) { |
68 |
if(tid_return) { |
69 |
@@ -2750,5 +2750,5 @@ |
69 |
@@ -2912,5 +2912,5 @@ |
70 |
long l; |
70 |
long l; |
71 |
char *q; |
71 |
char *q; |
72 |
- l = strtol((char*)p + 3, &q, 10); |
72 |
- l = strtol((char*)p + 3, &q, 10); |
Lines 73-107
Link Here
|
73 |
+ l = strtol((const char*)p + 3, &q, 10); |
73 |
+ l = strtol((const char*)p + 3, &q, 10); |
74 |
if(q && *q == ':' && l > 0 && l < *tid_len) { |
74 |
if(q && *q == ':' && l > 0 && l < *tid_len) { |
75 |
CHECK(q + 1, l); |
75 |
CHECK(q + 1, l); |
76 |
@@ -2782,5 +2782,5 @@ |
76 |
@@ -2944,5 +2944,5 @@ |
77 |
long l; |
77 |
long l; |
78 |
char *q; |
78 |
char *q; |
79 |
- l = strtol((char*)p + 5, &q, 10); |
79 |
- l = strtol((char*)p + 7, &q, 10); |
80 |
+ l = strtol((const char*)p + 5, &q, 10); |
80 |
+ l = strtol((const char*)p + 7, &q, 10); |
81 |
if(q && *q == 'e' && l > 0 && l < 0x10000) |
81 |
if(q && *q == 'e' && l > 0 && l < 0x10000) |
82 |
*port_return = l; |
82 |
*port_return = l; |
83 |
@@ -2804,5 +2804,5 @@ |
83 |
@@ -2957,5 +2957,5 @@ |
84 |
long l; |
84 |
long l; |
85 |
char *q; |
85 |
char *q; |
|
|
86 |
- l = strtol((char*)p + 16, &q, 10); |
87 |
+ l = strtol((const char*)p + 16, &q, 10); |
88 |
if(q && *q == 'e' && l > 0 && l < 0x10000) |
89 |
*implied_port_return = l; |
90 |
@@ -2979,5 +2979,5 @@ |
91 |
long l; |
92 |
char *q; |
86 |
- l = strtol((char*)p + 7, &q, 10); |
93 |
- l = strtol((char*)p + 7, &q, 10); |
87 |
+ l = strtol((const char*)p + 7, &q, 10); |
94 |
+ l = strtol((const char*)p + 7, &q, 10); |
88 |
if(q && *q == ':' && l > 0 && l < *token_len) { |
95 |
if(q && *q == ':' && l > 0 && l < *token_len) { |
89 |
CHECK(q + 1, l); |
96 |
CHECK(q + 1, l); |
90 |
@@ -2820,5 +2820,5 @@ |
97 |
@@ -2995,5 +2995,5 @@ |
91 |
long l; |
98 |
long l; |
92 |
char *q; |
99 |
char *q; |
93 |
- l = strtol((char*)p + 7, &q, 10); |
100 |
- l = strtol((char*)p + 7, &q, 10); |
94 |
+ l = strtol((const char*)p + 7, &q, 10); |
101 |
+ l = strtol((const char*)p + 7, &q, 10); |
95 |
if(q && *q == ':' && l > 0 && l < *nodes_len) { |
102 |
if(q && *q == ':' && l > 0 && l <= *nodes_len) { |
96 |
CHECK(q + 1, l); |
103 |
CHECK(q + 1, l); |
97 |
@@ -2836,5 +2836,5 @@ |
104 |
@@ -3011,5 +3011,5 @@ |
98 |
long l; |
105 |
long l; |
99 |
char *q; |
106 |
char *q; |
100 |
- l = strtol((char*)p + 8, &q, 10); |
107 |
- l = strtol((char*)p + 8, &q, 10); |
101 |
+ l = strtol((const char*)p + 8, &q, 10); |
108 |
+ l = strtol((const char*)p + 8, &q, 10); |
102 |
if(q && *q == ':' && l > 0 && l < *nodes6_len) { |
109 |
if(q && *q == ':' && l > 0 && l <= *nodes6_len) { |
103 |
CHECK(q + 1, l); |
110 |
CHECK(q + 1, l); |
104 |
@@ -2855,8 +2855,8 @@ |
111 |
@@ -3030,5 +3030,5 @@ |
105 |
long l; |
112 |
long l; |
106 |
char *q; |
113 |
char *q; |
107 |
- l = strtol((char*)buf + i, &q, 10); |
114 |
- l = strtol((char*)buf + i, &q, 10); |
Lines 108-114
Link Here
|
108 |
+ l = strtol((const char*)buf + i, &q, 10); |
115 |
+ l = strtol((const char*)buf + i, &q, 10); |
109 |
if(q && *q == ':' && l > 0) { |
116 |
if(q && *q == ':' && l > 0) { |
110 |
CHECK(q + 1, l); |
117 |
CHECK(q + 1, l); |
111 |
- i = q + 1 + l - (char*)buf; |
|
|
112 |
+ i = q + 1 + l - (const char*)buf; |
113 |
if(l == 6) { |
114 |
if(j + l > *values_len) |