... | ... |
@@ -40,7 +40,7 @@ export makefile_defs |
40 | 40 |
VERSION = 0 |
41 | 41 |
PATCHLEVEL = 8 |
42 | 42 |
SUBLEVEL = 12 |
43 |
-EXTRAVERSION = dev-t13 |
|
43 |
+EXTRAVERSION = dev-t14 |
|
44 | 44 |
|
45 | 45 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
46 | 46 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -18,6 +18,7 @@ release: |
18 | 18 |
- backport: acc mem. leak fixes |
19 | 19 |
- backport: dns mem. leak fixes (resolve.[ch]) |
20 | 20 |
- backport: id_builder receive_msg mem. leak (receive.c) |
21 |
+- backport: check_self ipv6/case fixes (forward.c) |
|
21 | 22 |
- change tcp timeouts to 2 or 3 min? |
22 | 23 |
x check via ipv6 fixes and backport to stable |
23 | 24 |
x fix kill(0, SIGTERM) on startup error (will kill also the launching shell |
... | ... |
@@ -41,6 +41,7 @@ |
41 | 41 |
* local replies & "normal" replies (andrei) |
42 | 42 |
* 2003-04-12 update_sock_struct_form via uses also FL_FORCE_RPORT for |
43 | 43 |
* local replies (andrei) |
44 |
+ * 2003-08-21 check_self properly handles ipv6 addresses & refs (andrei) |
|
44 | 45 |
*/ |
45 | 46 |
|
46 | 47 |
|
... | ... |
@@ -220,21 +221,38 @@ struct socket_info* get_send_socket(union sockaddr_union* to, int proto) |
220 | 221 |
/* checks if the host:port is one of the address we listen on; |
221 | 222 |
* if port==0, the port number is ignored |
222 | 223 |
* returns 1 if true, 0 if false, -1 on error |
223 |
-*/ |
|
224 |
+ * WARNING: uses str2ip6 so it will overwrite any previous |
|
225 |
+ * unsaved result of this function (static buffer) |
|
226 |
+ */ |
|
224 | 227 |
int check_self(str* host, unsigned short port) |
225 | 228 |
{ |
226 | 229 |
int r; |
230 |
+ char* hname; |
|
231 |
+ int h_len; |
|
232 |
+#ifdef USE_IPV6 |
|
233 |
+ struct ip_addr* ip6; |
|
234 |
+#endif |
|
227 | 235 |
|
236 |
+ h_len=host->len; |
|
237 |
+ hname=host->s; |
|
238 |
+#ifdef USE_IPV6 |
|
239 |
+ if ((h_len>2)&&((*hname)=='[')&&(hname[h_len-1]==']')){ |
|
240 |
+ /* ipv6 reference, skip [] */ |
|
241 |
+ hname++; |
|
242 |
+ h_len-=2; |
|
243 |
+ } |
|
244 |
+#endif |
|
228 | 245 |
for (r=0; r<sock_no; r++){ |
229 | 246 |
DBG("check_self - checking if host==us: %d==%d && " |
230 | 247 |
" [%.*s] == [%.*s]\n", |
231 |
- host->len, |
|
248 |
+ h_len, |
|
232 | 249 |
sock_info[r].name.len, |
233 |
- host->len, host->s, |
|
250 |
+ h_len, hname, |
|
234 | 251 |
sock_info[r].name.len, sock_info[r].name.s |
235 | 252 |
); |
236 | 253 |
if (port) { |
237 |
- DBG("check_self - checking if port %d matches port %d\n", sock_info[r].port_no, port); |
|
254 |
+ DBG("check_self - checking if port %d matches port %d\n", |
|
255 |
+ sock_info[r].port_no, port); |
|
238 | 256 |
#ifdef USE_TLS |
239 | 257 |
if ((sock_info[r].port_no!=port) && (tls_info[r].port_no!=port)) { |
240 | 258 |
#else |
... | ... |
@@ -243,32 +261,31 @@ int check_self(str* host, unsigned short port) |
243 | 261 |
continue; |
244 | 262 |
} |
245 | 263 |
} |
246 |
- if ( (host->len==sock_info[r].name.len) && |
|
247 |
-#ifdef USE_IPV6 |
|
248 |
- (strncasecmp(host->s, sock_info[r].name.s, |
|
249 |
- sock_info[r].name.len)==0) /*slower*/ |
|
250 |
-#else |
|
251 |
- (memcmp(host->s, sock_info[r].name.s, |
|
252 |
- sock_info[r].name.len)==0) |
|
253 |
-#endif |
|
254 |
- ) |
|
264 |
+ if ( (h_len==sock_info[r].name.len) && |
|
265 |
+ (strncasecmp(hname, sock_info[r].name.s, |
|
266 |
+ sock_info[r].name.len)==0) /*slower*/) |
|
267 |
+ /* comp. must be case insensitive, host names |
|
268 |
+ * can be written in mixed case, it will also match |
|
269 |
+ * ipv6 addresses */ |
|
255 | 270 |
break; |
256 | 271 |
/* check if host == ip address */ |
257 |
- if ( (!sock_info[r].is_ip) && |
|
258 |
- (host->len==sock_info[r].address_str.len) && |
|
259 | 272 |
#ifdef USE_IPV6 |
260 |
- (strncasecmp(host->s, sock_info[r].address_str.s, |
|
261 |
- sock_info[r].address_str.len)==0) /*slower*/ |
|
262 |
-#else |
|
263 |
- (memcmp(host->s, sock_info[r].address_str.s, |
|
264 |
- sock_info[r].address_str.len)==0) |
|
273 |
+ /* ipv6 case is uglier, host can be [3ffe::1] */ |
|
274 |
+ ip6=str2ip6(host); |
|
275 |
+ if ((ip6) && ip_addr_cmp(ip6, &sock_info[r].address)) |
|
276 |
+ break; /* match */ |
|
265 | 277 |
#endif |
278 |
+ /* ipv4 */ |
|
279 |
+ if ( (!sock_info[r].is_ip) && |
|
280 |
+ (h_len==sock_info[r].address_str.len) && |
|
281 |
+ (memcmp(hname, sock_info[r].address_str.s, |
|
282 |
+ sock_info[r].address_str.len)==0) |
|
266 | 283 |
) |
267 | 284 |
break; |
268 | 285 |
} |
269 | 286 |
if (r==sock_no){ |
270 | 287 |
/* try to look into the aliases*/ |
271 |
- if (grep_aliases(host->s, host->len, port)==0){ |
|
288 |
+ if (grep_aliases(hname, h_len, port)==0){ |
|
272 | 289 |
DBG("check_self: host != me\n"); |
273 | 290 |
return 0; |
274 | 291 |
} |
... | ... |
@@ -57,7 +57,8 @@ static inline int grep_aliases(char* name, int len, unsigned short port) |
57 | 57 |
|
58 | 58 |
for(a=aliases;a;a=a->next) |
59 | 59 |
#ifdef USE_TLS |
60 |
- if ((a->alias.len==len) && ((a->port==0) || (port==0) || (port==tls_port_no) || |
|
60 |
+ if ((a->alias.len==len) && ((a->port==0) || (port==0) || |
|
61 |
+ (port==tls_port_no) || |
|
61 | 62 |
#else |
62 | 63 |
if ((a->alias.len==len) && ((a->port==0) || (port==0) || |
63 | 64 |
#endif |