Fix loop in RR sort.

This commit is contained in:
Simon Kelley
2014-01-21 20:17:40 +00:00
parent 39048ad10b
commit 6fd6dacb39

View File

@@ -457,7 +457,7 @@ static void sort_rrset(struct dns_header *header, size_t plen, u16 *rr_desc, int
else else
left2 = len2 - len1, left1 = 0, len = len1; left2 = len2 - len1, left1 = 0, len = len1;
rc = memcmp(buff1, buff2, len); rc = (len == 0) ? 0 : memcmp(buff1, buff2, len);
if (rc > 0 || (rc == 0 && quit && len1 > len2)) if (rc > 0 || (rc == 0 && quit && len1 > len2))
{ {
@@ -466,6 +466,8 @@ static void sort_rrset(struct dns_header *header, size_t plen, u16 *rr_desc, int
rrset[i] = tmp; rrset[i] = tmp;
swap = quit = 1; swap = quit = 1;
} }
else if (rc < 0)
quit = 1;
} }
} }
} while (swap); } while (swap);