The changes in make_sec_desc to make us match W2K broke the marshalling/unmarshalling of
authorJeremy Allison <jra@samba.org>
Fri, 12 Jul 2002 21:09:24 +0000 (21:09 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 12 Jul 2002 21:09:24 +0000 (21:09 +0000)
security descriptors. We need to calculate the maximum offset and set the offset
back after reading/writing every field in the SEC_DESC.
This was *nasty* to find....
Jeremy.
(This used to be commit 175d43980e57c25582d8ab859f5730283e82f3b2)

source3/lib/charcnv.c
source3/rpc_parse/parse_sec.c

index a6db2861344a92c2384d976e6a36567ef2576c8a..d42dc994b0032b90e90c06dedac65648d3c7530a 100644 (file)
@@ -143,7 +143,7 @@ size_t convert_string(charset_t from, charset_t to,
                switch(errno)
                { case EINVAL: reason="Incomplete multibyte sequence"; break;
                  case E2BIG:  reason="No more room"; 
-                              DEBUG(0, ("Required %d, available %d\n",
+                              DEBUG(0, ("convert_string: Required %d, available %d\n",
                               srclen, destlen));
                               /* we are not sure we need srclen bytes,
                                  may be more, may be less.
index 8ae8264d6d572d41c6d62d7a3df252c78fb63e38..56eaf4c5b5c98e77a3a4e78b895df331289d938e 100644 (file)
@@ -782,64 +782,69 @@ BOOL sec_io_desc(char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth)
 
        if (psd->off_owner_sid != 0) {
 
+               tmp_offset = ps->data_offset;
+               if(!prs_set_offset(ps, old_offset + psd->off_owner_sid))
+                       return False;
+
                if (UNMARSHALLING(ps)) {
-                       if(!prs_set_offset(ps, old_offset + psd->off_owner_sid))
-                               return False;
                        /* reading */
                        if((psd->owner_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->owner_sid))) == NULL)
                                return False;
                }
 
-               tmp_offset = ps->data_offset;
-               ps->data_offset = psd->off_owner_sid;
-
                if(!smb_io_dom_sid("owner_sid ", psd->owner_sid , ps, depth))
                        return False;
 
-               ps->data_offset = tmp_offset;
-       }
+               max_offset = MAX(max_offset, prs_offset(ps));
 
-       max_offset = MAX(max_offset, prs_offset(ps));
+               if (!prs_set_offset(ps,tmp_offset))
+                       return False;
+       }
 
        if (psd->off_grp_sid != 0) {
 
+               tmp_offset = ps->data_offset;
+               if(!prs_set_offset(ps, old_offset + psd->off_grp_sid))
+                       return False;
+
                if (UNMARSHALLING(ps)) {
                        /* reading */
-                       if(!prs_set_offset(ps, old_offset + psd->off_grp_sid))
-                               return False;
                        if((psd->grp_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->grp_sid))) == NULL)
                                return False;
                }
 
-               tmp_offset = ps->data_offset;
-               ps->data_offset = psd->off_grp_sid;
-
                if(!smb_io_dom_sid("grp_sid", psd->grp_sid, ps, depth))
                        return False;
                        
-               ps->data_offset = tmp_offset;
-       }
+               max_offset = MAX(max_offset, prs_offset(ps));
 
-       max_offset = MAX(max_offset, prs_offset(ps));
+               if (!prs_set_offset(ps,tmp_offset))
+                       return False;
+       }
 
        if ((psd->type & SEC_DESC_SACL_PRESENT) && psd->off_sacl) {
+               tmp_offset = ps->data_offset;
                if(!prs_set_offset(ps, old_offset + psd->off_sacl))
                        return False;
                if(!sec_io_acl("sacl", &psd->sacl, ps, depth))
                        return False;
+               max_offset = MAX(max_offset, prs_offset(ps));
+               if (!prs_set_offset(ps,tmp_offset))
+                       return False;
        }
 
-       max_offset = MAX(max_offset, prs_offset(ps));
 
        if ((psd->type & SEC_DESC_DACL_PRESENT) && psd->off_dacl != 0) {
+               tmp_offset = ps->data_offset;
                if(!prs_set_offset(ps, old_offset + psd->off_dacl))
                        return False;
                if(!sec_io_acl("dacl", &psd->dacl, ps, depth))
                        return False;
+               max_offset = MAX(max_offset, prs_offset(ps));
+               if (!prs_set_offset(ps,tmp_offset))
+                       return False;
        }
 
-       max_offset = MAX(max_offset, prs_offset(ps));
-
        if(!prs_set_offset(ps, max_offset))
                return False;
        return True;