s3-dns: prevent from potentially doing wrong SRV DNS lookups.
[mat/samba.git] / source3 / libads / dns.c
index 152003941b52bac16b55f3a5b6aca36d938ae772..39454fcebc099199e1edaecc1b62c7e2fe4ad981 100644 (file)
@@ -328,7 +328,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
                buf_len = resp_len * sizeof(uint8);
 
                if (buf_len) {
-                       if ((buffer = TALLOC_ARRAY(ctx, uint8, buf_len))
+                       if ((buffer = talloc_array(ctx, uint8, buf_len))
                                        == NULL ) {
                                DEBUG(0,("ads_dns_lookup_srv: "
                                        "talloc() failed!\n"));
@@ -442,7 +442,7 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
                answer_count));
 
        if (answer_count) {
-               if ((dcs = TALLOC_ZERO_ARRAY(ctx, struct dns_rr_srv,
+               if ((dcs = talloc_zero_array(ctx, struct dns_rr_srv,
                                                answer_count)) == NULL ) {
                        DEBUG(0,("ads_dns_lookup_srv: "
                                "talloc() failure for %d char*'s\n",
@@ -534,13 +534,13 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
                                /* allocate new memory */
 
                                if (dcs[i].num_ips == 0) {
-                                       if ((dcs[i].ss_s = TALLOC_ARRAY(dcs,
+                                       if ((dcs[i].ss_s = talloc_array(dcs,
                                                struct sockaddr_storage, 1 ))
                                                        == NULL ) {
                                                return NT_STATUS_NO_MEMORY;
                                        }
                                } else {
-                                       if ((tmp_ss_s = TALLOC_REALLOC_ARRAY(dcs,
+                                       if ((tmp_ss_s = talloc_realloc(dcs,
                                                        dcs[i].ss_s,
                                                        struct sockaddr_storage,
                                                        dcs[i].num_ips+1))
@@ -638,7 +638,7 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
                answer_count));
 
        if (answer_count) {
-               if ((nsarray = TALLOC_ARRAY(ctx, struct dns_rr_ns,
+               if ((nsarray = talloc_array(ctx, struct dns_rr_ns,
                                                answer_count)) == NULL ) {
                        DEBUG(0,("ads_dns_lookup_ns: "
                                "talloc() failure for %d char*'s\n",
@@ -756,7 +756,7 @@ static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
                                       int *numdcs )
 {
        char *name;
-       if (sitename) {
+       if (sitename && strlen(sitename)) {
                name = talloc_asprintf(ctx, "%s._tcp.%s._sites.%s._msdcs.%s",
                                       servicename, sitename,
                                       dc_pdc_gc_domains, realm);