Lines 1-6
Link Here
|
1 |
--- dht.c 2018-02-09 16:44:37.000000000 -0500 |
1 |
--- dht.c 2018-12-16 08:38:37.000000000 -0500 |
2 |
+++ dht.c 2018-12-02 18:00:11.873381000 -0500 |
2 |
+++ dht.c 2018-12-30 19:22:30.679020000 -0500 |
3 |
@@ -365,5 +365,5 @@ |
3 |
@@ -382,5 +382,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 |
@@ -373,5 +373,5 @@ |
10 |
@@ -390,5 +390,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 |
@@ -1427,13 +1427,13 @@ |
17 |
@@ -1444,13 +1444,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 |
@@ -1552,15 +1552,15 @@ |
36 |
@@ -1569,15 +1569,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 |
@@ -2038,5 +2038,5 @@ |
55 |
@@ -2047,5 +2047,5 @@ |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
- if(((char*)buf)[buflen] != '\0') { |
58 |
- if(((char*)buf)[buflen] != '\0') { |
Lines 59-117
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 |
@@ -2905,5 +2905,5 @@ |
62 |
@@ -2904,5 +2904,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; |
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 |
p = dht_memmem(buf, buflen, "1:t", 3); |
69 |
@@ -2912,5 +2912,5 @@ |
69 |
@@ -2910,5 +2910,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); |
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 < PARSE_TID_LEN) { |
75 |
CHECK(q + 1, l); |
75 |
CHECK(q + 1, l); |
76 |
@@ -2944,5 +2944,5 @@ |
76 |
@@ -2934,5 +2934,5 @@ |
77 |
long l; |
77 |
long l; |
78 |
char *q; |
78 |
char *q; |
79 |
- l = strtol((char*)p + 7, &q, 10); |
79 |
- l = strtol((char*)p + 7, &q, 10); |
80 |
+ l = strtol((const char*)p + 7, &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 |
m->port = l; |
83 |
@@ -2957,5 +2957,5 @@ |
83 |
@@ -2943,5 +2943,5 @@ |
84 |
long l; |
84 |
long l; |
85 |
char *q; |
85 |
char *q; |
86 |
- l = strtol((char*)p + 16, &q, 10); |
86 |
- l = strtol((char*)p + 16, &q, 10); |
87 |
+ l = strtol((const char*)p + 16, &q, 10); |
87 |
+ l = strtol((const char*)p + 16, &q, 10); |
88 |
if(q && *q == 'e' && l > 0 && l < 0x10000) |
88 |
if(q && *q == 'e' && l > 0 && l < 0x10000) |
89 |
*implied_port_return = l; |
89 |
m->implied_port = l; |
90 |
@@ -2979,5 +2979,5 @@ |
90 |
@@ -2958,5 +2958,5 @@ |
91 |
long l; |
91 |
long l; |
92 |
char *q; |
92 |
char *q; |
93 |
- l = strtol((char*)p + 7, &q, 10); |
93 |
- l = strtol((char*)p + 7, &q, 10); |
94 |
+ l = strtol((const char*)p + 7, &q, 10); |
94 |
+ l = strtol((const char*)p + 7, &q, 10); |
95 |
if(q && *q == ':' && l > 0 && l < *token_len) { |
95 |
if(q && *q == ':' && l > 0 && l < PARSE_TOKEN_LEN) { |
96 |
CHECK(q + 1, l); |
96 |
CHECK(q + 1, l); |
97 |
@@ -2995,5 +2995,5 @@ |
97 |
@@ -2970,5 +2970,5 @@ |
98 |
long l; |
98 |
long l; |
99 |
char *q; |
99 |
char *q; |
100 |
- l = strtol((char*)p + 7, &q, 10); |
100 |
- l = strtol((char*)p + 7, &q, 10); |
101 |
+ l = strtol((const char*)p + 7, &q, 10); |
101 |
+ l = strtol((const char*)p + 7, &q, 10); |
102 |
if(q && *q == ':' && l > 0 && l <= *nodes_len) { |
102 |
if(q && *q == ':' && l > 0 && l <= PARSE_NODES_LEN) { |
103 |
CHECK(q + 1, l); |
103 |
CHECK(q + 1, l); |
104 |
@@ -3011,5 +3011,5 @@ |
104 |
@@ -2982,5 +2982,5 @@ |
105 |
long l; |
105 |
long l; |
106 |
char *q; |
106 |
char *q; |
107 |
- l = strtol((char*)p + 8, &q, 10); |
107 |
- l = strtol((char*)p + 8, &q, 10); |
108 |
+ l = strtol((const char*)p + 8, &q, 10); |
108 |
+ l = strtol((const char*)p + 8, &q, 10); |
109 |
if(q && *q == ':' && l > 0 && l <= *nodes6_len) { |
109 |
if(q && *q == ':' && l > 0 && l <= PARSE_NODES6_LEN) { |
110 |
CHECK(q + 1, l); |
110 |
CHECK(q + 1, l); |
111 |
@@ -3030,5 +3030,5 @@ |
|
|
112 |
long l; |
113 |
char *q; |
114 |
- l = strtol((char*)buf + i, &q, 10); |
115 |
+ l = strtol((const char*)buf + i, &q, 10); |
116 |
if(q && *q == ':' && l > 0) { |
117 |
CHECK(q + 1, l); |