In this comparison function a NULL string is treated as the ancestor
of all names, but you need to look hard to see that.
By pulling the logic for NULLs to the front, hopefully we have to look
less hard.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
uint16_t comp2[UINT8_MAX] = {0};
size_t i;
- if (s1 != NULL) {
- l1 = strlen(s1);
+ if (s1 == s2) {
+ /* this includes the both NULL case */
+ return DNS_CMP_MATCH;
}
-
- if (s2 != NULL) {
- l2 = strlen(s2);
+ if (s1 == NULL) {
+ return DNS_CMP_SECOND_IS_CHILD;
+ }
+ if (s2 == NULL) {
+ return DNS_CMP_FIRST_IS_CHILD;
}
+ l1 = strlen(s1);
+ l2 = strlen(s2);
+
/*
* trailing '.' are ignored.
*/