FreeBSD Bugzilla – Attachment 63973 Details for
Bug 95277
[netinet] [patch] IP Encapsulation mask_match() returns wrong results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
maskmatch.diff
maskmatch.diff (text/x-patch), 1.73 KB, created by
Bruce M Simpson
on 2006-09-28 18:22:46 UTC
(
hide
)
Description:
maskmatch.diff
Filename:
MIME Type:
Creator:
Bruce M Simpson
Created:
2006-09-28 18:22:46 UTC
Size:
1.73 KB
patch
obsolete
>==== //depot/user/bms/nethead/sys/netinet/ip_encap.c#1 - /home/bms/fp4/nethead/sys/netinet/ip_encap.c ==== >--- /tmp/tmp.41786.0 Thu Sep 28 18:21:51 2006 >+++ /home/bms/fp4/nethead/sys/netinet/ip_encap.c Thu Sep 28 18:21:09 2006 >@@ -403,6 +403,7 @@ > const struct sockaddr *sp; > const struct sockaddr *dp; > { >+ const int hdrlen = offsetof(struct sockaddr, sa_data); > struct sockaddr_storage s; > struct sockaddr_storage d; > int i; >@@ -419,32 +420,28 @@ > > matchlen = 0; > >- p = (const u_int8_t *)sp; >- q = (const u_int8_t *)&ep->srcmask; >- r = (u_int8_t *)&s; >- for (i = 0 ; i < sp->sa_len; i++) { >+ p = (const u_int8_t *)&sp->sa_data; >+ q = (const u_int8_t *)&ep->srcmask + hdrlen; >+ r = (u_int8_t *)&s + hdrlen; >+ for (i = 0 ; i < sp->sa_len - hdrlen; i++) { > r[i] = p[i] & q[i]; > /* XXX estimate */ > matchlen += (q[i] ? 8 : 0); > } > >- p = (const u_int8_t *)dp; >- q = (const u_int8_t *)&ep->dstmask; >- r = (u_int8_t *)&d; >- for (i = 0 ; i < dp->sa_len; i++) { >+ p = (const u_int8_t *)&dp->sa_data; >+ q = (const u_int8_t *)&ep->dstmask + hdrlen; >+ r = (u_int8_t *)&d + hdrlen; >+ for (i = 0 ; i < dp->sa_len - hdrlen; i++) { > r[i] = p[i] & q[i]; > /* XXX rough estimate */ > matchlen += (q[i] ? 8 : 0); > } > >- /* need to overwrite len/family portion as we don't compare them */ >- s.ss_len = sp->sa_len; >- s.ss_family = sp->sa_family; >- d.ss_len = dp->sa_len; >- d.ss_family = dp->sa_family; >- >- if (bcmp(&s, &ep->src, ep->src.ss_len) == 0 && >- bcmp(&d, &ep->dst, ep->dst.ss_len) == 0) { >+ if (bcmp((u_int8_t *)&s + hdrlen, (const u_int8_t *)&ep->src + hdrlen, >+ ep->src.ss_len - hdrlen) == 0 && >+ bcmp((u_int8_t *)&d + hdrlen, (const u_int8_t *)&ep->dst + hdrlen, >+ ep->dst.ss_len - hdrlen) == 0) { > return matchlen; > } else > return 0;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 95277
:
63972
| 63973