Summary: | [PATCH] getaddrinfo doesn't implement sort rule 10 deterministically | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Herbie.Robinson | ||||
Component: | bin | Assignee: | Andrey A. Chernov <ache> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Many People | CC: | ache | ||||
Priority: | --- | Keywords: | patch | ||||
Version: | CURRENT | Flags: | ache:
mfc-stable11+
ache: mfc-stable10+ |
||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
Herbie.Robinson
2016-08-24 20:04:38 UTC
Created attachment 174026 [details]
patch for Revision 304034 (head)
irc.warped.net is a good test case for this... Turn on debug and make sure the getaddrinfo results are sorted the same way they come from DNS (which changes every time). A commit references this bug: Author: ache Date: Sat Aug 27 14:43:13 UTC 2016 New revision: 304911 URL: https://svnweb.freebsd.org/changeset/base/304911 Log: The formal behavior of qsort is unstable with regard to objects that are equal. Unfortunately, RFC 3484 requires that otherwise equal objects remain in the order supplied by the DNS server. The present code attempts to deal with this by returning -1 for objects that are equal (i.e., returns that the first parameter is less then the second parameter). Unfortunately, the qsort API does not state that the first parameter passed in is in any particular position in the list. PR: 212122 Submitted by: Herbie.Robinson@stratus.com MFC after: 3 days Changes: head/lib/libc/net/getaddrinfo.c A commit references this bug: Author: ache Date: Tue Aug 30 00:57:57 UTC 2016 New revision: 305037 URL: https://svnweb.freebsd.org/changeset/base/305037 Log: MFC r304911 The formal behavior of qsort is unstable with regard to objects that are equal. Unfortunately, RFC 3484 requires that otherwise equal objects remain in the order supplied by the DNS server. The present code attempts to deal with this by returning -1 for objects that are equal (i.e., returns that the first parameter is less then the second parameter). Unfortunately, the qsort API does not state that the first parameter passed in is in any particular position in the list. PR: 212122 Submitted by: Herbie.Robinson@stratus.com Changes: _U stable/10/ stable/10/lib/libc/net/getaddrinfo.c A commit references this bug: Author: ache Date: Tue Aug 30 01:01:42 UTC 2016 New revision: 305038 URL: https://svnweb.freebsd.org/changeset/base/305038 Log: MFC r304911 The formal behavior of qsort is unstable with regard to objects that are equal. Unfortunately, RFC 3484 requires that otherwise equal objects remain in the order supplied by the DNS server. The present code attempts to deal with this by returning -1 for objects that are equal (i.e., returns that the first parameter is less then the second parameter). Unfortunately, the qsort API does not state that the first parameter passed in is in any particular position in the list. PR: 212122 Submitted by: Herbie.Robinson@stratus.com Changes: _U stable/11/ stable/11/lib/libc/net/getaddrinfo.c |