Author: jra
Date: 2007-04-29 19:54:26 +0000 (Sun, 29 Apr 2007)
New Revision: 22574

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22574

Log:
Fix reply when we have no dfs shares.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/rpc_server/srv_dfs_nt.c
   branches/SAMBA_3_0_25/source/rpc_server/srv_dfs_nt.c


Changeset:
Modified: branches/SAMBA_3_0/source/rpc_server/srv_dfs_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_dfs_nt.c   2007-04-29 19:20:48 UTC 
(rev 22573)
+++ branches/SAMBA_3_0/source/rpc_server/srv_dfs_nt.c   2007-04-29 19:54:26 UTC 
(rev 22574)
@@ -211,12 +211,15 @@
        dfs3->num_stores = j->referral_count;
     
        /* also enumerate the stores */
-       dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, 
j->referral_count);
-       if (!dfs3->stores)
-               return False;
+       if (j->referral_count) {
+               dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, 
j->referral_count);
+               if (!dfs3->stores)
+                       return False;
+               memset(dfs3->stores, '\0', j->referral_count * sizeof(struct 
dfs_StorageInfo));
+       } else {
+               dfs3->stores = NULL;
+       }
 
-       memset(dfs3->stores, '\0', j->referral_count * sizeof(struct 
dfs_StorageInfo));
-
        for(ii=0;ii<j->referral_count;ii++) {
                char* p; 
                pstring path;
@@ -262,20 +265,32 @@
        /* Create the return array */
        switch (r->in.level) {
        case 1:
-               if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct 
dfs_Info1, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               if (num_jn) {
+                       if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, 
struct dfs_Info1, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+               } else {
+                       r->out.info->e.info1->s = NULL;
                }
                r->out.info->e.info1->count = num_jn;
                break;
        case 2:
-               if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct 
dfs_Info2, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               if (num_jn) {
+                       if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, 
struct dfs_Info2, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+               } else {
+                       r->out.info->e.info2->s = NULL;
                }
                r->out.info->e.info2->count = num_jn;
                break;
        case 3:
-               if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct 
dfs_Info3, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               if (num_jn) {
+                       if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, 
struct dfs_Info3, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+               } else {
+                       r->out.info->e.info3->s = NULL;
                }
                r->out.info->e.info3->count = num_jn;
                break;
@@ -301,7 +316,7 @@
   
        return WERR_OK;
 }
-      
+
 WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r)
 {
        int consumedcnt = sizeof(pstring);

Modified: branches/SAMBA_3_0_25/source/rpc_server/srv_dfs_nt.c
===================================================================
--- branches/SAMBA_3_0_25/source/rpc_server/srv_dfs_nt.c        2007-04-29 
19:20:48 UTC (rev 22573)
+++ branches/SAMBA_3_0_25/source/rpc_server/srv_dfs_nt.c        2007-04-29 
19:54:26 UTC (rev 22574)
@@ -233,15 +233,19 @@
        init_unistr2(&dfs3->comment, j->comment, UNI_STR_TERMINATE);
        dfs3->state = 1;
        dfs3->num_stores = dfs3->size_stores = j->referral_count;
-       dfs3->ptr0_stores = 1;
     
        /* also enumerate the stores */
-       dfs3->stores = TALLOC_ARRAY(ctx, NETDFS_DFS_STORAGEINFO, 
j->referral_count);
-       if (!dfs3->stores)
-               return False;
+       if (j->referral_count) {
+               dfs3->stores = TALLOC_ARRAY(ctx, NETDFS_DFS_STORAGEINFO, 
j->referral_count);
+               if (!dfs3->stores)
+                       return False;
+               memset(dfs3->stores, '\0', j->referral_count * 
sizeof(NETDFS_DFS_STORAGEINFO));
+               dfs3->ptr0_stores = 1;
+       } else {
+               dfs3->stores = NULL;
+               dfs3->ptr0_stores = 0;
+       }
 
-       memset(dfs3->stores, '\0', j->referral_count * 
sizeof(NETDFS_DFS_STORAGEINFO));
-
        for(ii=0;ii<j->referral_count;ii++) {
                char* p; 
                pstring path;
@@ -294,28 +298,34 @@
        /* Create the return array */
        switch (level) {
        case 1:
-               if ((r_u->info.e.u.info1.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO1, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               r_u->info.e.u.info1.count = num_jn;
+               if (num_jn) {
+                       if ((r_u->info.e.u.info1.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO1, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+                       r_u->info.e.u.info1.ptr0_s = 1;
+                       r_u->info.e.u.info1.size_s = num_jn;
                }
-               r_u->info.e.u.info1.count = num_jn;
-               r_u->info.e.u.info1.ptr0_s = 1;
-               r_u->info.e.u.info1.size_s = num_jn;
                break;
        case 2:
-               if ((r_u->info.e.u.info2.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO2, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               r_u->info.e.u.info2.count = num_jn;
+               if (num_jn) {
+                       if ((r_u->info.e.u.info2.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO2, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+                       r_u->info.e.u.info2.ptr0_s = 1;
+                       r_u->info.e.u.info2.size_s = num_jn;
                }
-               r_u->info.e.u.info2.count = num_jn;
-               r_u->info.e.u.info2.ptr0_s = 1;
-               r_u->info.e.u.info2.size_s = num_jn;
                break;
        case 3:
-               if ((r_u->info.e.u.info3.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO3, num_jn)) == NULL) {
-                       return WERR_NOMEM;
+               r_u->info.e.u.info3.count = num_jn;
+               if (num_jn) {
+                       if ((r_u->info.e.u.info3.s = TALLOC_ARRAY(p->mem_ctx, 
NETDFS_DFS_INFO3, num_jn)) == NULL) {
+                               return WERR_NOMEM;
+                       }
+                       r_u->info.e.u.info3.ptr0_s = 1;
+                       r_u->info.e.u.info3.size_s = num_jn;
                }
-               r_u->info.e.u.info3.count = num_jn;
-               r_u->info.e.u.info3.ptr0_s = 1;
-               r_u->info.e.u.info3.size_s = num_jn;
                break;
        default:
                return WERR_INVALID_PARAM;

Reply via email to