dns: cope with trailing '.' in dns_name
authorAndrew Tridgell <tridge@samba.org>
Tue, 21 Dec 2010 09:52:24 +0000 (20:52 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 21 Dec 2010 10:18:20 +0000 (11:18 +0100)
librpc/ndr/ndr_dnsp.c

index ae78425c55bd4204685de225d2ca4f2d488b8869..daf8fffdef57c0ca0cfca94aad66d12215d900be 100644 (file)
@@ -95,7 +95,13 @@ enum ndr_err_code ndr_push_dnsp_name(struct ndr_push *ndr, int ndr_flags, const
        for (count=i=0; name[i]; i++) {
                if (name[i] == '.') count++;
        }
-       total_len = strlen(name) + 1 + 1;
+       total_len = strlen(name) + 1;
+
+       /* cope with names ending in '.' */
+       if (name[strlen(name)-1] != '.') {
+               total_len++;
+               count++;
+       }
        if (total_len > 255 || count > 255) {
                return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
                                      "dns_name of length %d larger than 255", total_len);