FreeBSD Bugzilla – Attachment 174026 Details for
Bug 212122
[PATCH] getaddrinfo doesn't implement sort rule 10 deterministically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for Revision 304034 (head)
rule_10_patch.txt (text/plain), 1.28 KB, created by
Herbie.Robinson
on 2016-08-24 20:07:46 UTC
(
hide
)
Description:
patch for Revision 304034 (head)
Filename:
MIME Type:
Creator:
Herbie.Robinson
Created:
2016-08-24 20:07:46 UTC
Size:
1.28 KB
patch
obsolete
>--- getaddrinfo.c.orig 2016-08-24 15:43:12 -0400 >+++ getaddrinfo.c 2016-08-24 15:45:50 -0400 >@@ -224,6 +224,7 @@ > struct policyqueue *aio_dstpolicy; > struct addrinfo *aio_ai; > int aio_matchlen; >+ int aio_initial_sequence; > }; > > static const ns_src default_dns_files[] = { >@@ -708,6 +709,7 @@ > aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr, > &policyhead); > set_source(&aio[i], &policyhead); >+ aio[i].aio_initial_sequence = i; > } > > /* perform sorting. */ >@@ -1066,6 +1068,23 @@ > } > > /* Rule 10: Otherwise, leave the order unchanged. */ >+ >+ /* >+ * Note that qsort is unstable; so, we can't return zero and >+ * expect the order to be unchanged. >+ * That also means we can't depend on the current position of >+ * dst2 being after dst1. We must enforce the initial order >+ * with an explicit compare on the original position. >+ * The qsort specification requires that "When the same objects >+ * (consisting of width bytes, irrespective of their current >+ * positions in the array) are passed more than once to the >+ * comparison function, the results shall be consistent with one >+ * another." >+ * In other words, If A < B, then we must also return B > A. >+ */ >+ if (dst2->aio_initial_sequence < dst1->aio_initial_sequence) >+ return(1); >+ > return(-1); > } >
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 212122
: 174026