dnsserver: Stop dns_name_equal doing OOB read
authorGarming Sam <garming@catalyst.net.nz>
Thu, 1 Jun 2017 02:36:07 +0000 (14:36 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 1 Jun 2017 17:34:38 +0000 (19:34 +0200)
This has been the cause of a large number of flakey autobuilds. Every
now and again dns_name_equal would not be equal between two empty
strings, thus causing failures.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12813

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Jun  1 19:34:38 CEST 2017 on sn-devel-144

source4/rpc_server/dnsserver/dnsdata.c

index 9b3c9f9d4065279db2ef11ea522c2e47e0fafffc..c300643351564ae8ebf980b926a61556bc807a4b 100644 (file)
@@ -1127,8 +1127,8 @@ bool dns_name_equal(const char *name1, const char *name2)
        size_t len1 = strlen(name1);
        size_t len2 = strlen(name2);
 
-       if (name1[len1-1] == '.') len1--;
-       if (name2[len2-1] == '.') len2--;
+       if (len1 > 0 && name1[len1-1] == '.') len1--;
+       if (len2 > 0 && name2[len2-1] == '.') len2--;
        if (len1 != len2) {
                return false;
        }