Ignore:
Timestamp:
May 24, 2009, 7:17:10 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 to 3.3.1

Location:
branches/samba-3.3.x/source/registry
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/registry/reg_backend_db.c

    r206 r221  
    537537
    538538        for (i=0; i<num_subkeys; i++) {
    539                 len += tdb_pack(buffer+len, buflen-len, "f",
    540                                 regsubkey_ctr_specific_key(ctr, i));
    541                 if (len > buflen) {
    542                         /* allocate some extra space */
    543                         buffer = (uint8 *)SMB_REALLOC(buffer, len*2);
     539                size_t thistime;
     540
     541                thistime = tdb_pack(buffer+len, buflen-len, "f",
     542                                    regsubkey_ctr_specific_key(ctr, i));
     543                if (len+thistime > buflen) {
     544                        size_t thistime2;
     545                        /*
     546                         * tdb_pack hasn't done anything because of the short
     547                         * buffer, allocate extra space.
     548                         */
     549                        buffer = SMB_REALLOC_ARRAY(buffer, uint8_t,
     550                                                   (len+thistime)*2);
    544551                        if(buffer == NULL) {
    545552                                DEBUG(0, ("regdb_store_keys: Failed to realloc "
    546                                           "memory of size [%d]\n", len*2));
     553                                          "memory of size [%u]\n",
     554                                          (unsigned int)(len+thistime)*2));
    547555                                ret = false;
    548556                                goto done;
    549557                        }
    550                         buflen = len*2;
    551                         len = tdb_pack(buffer+len, buflen-len, "f",
    552                                        regsubkey_ctr_specific_key(ctr, i));
    553                 }
     558                        buflen = (len+thistime)*2;
     559                        thistime2 = tdb_pack(
     560                                buffer+len, buflen-len, "f",
     561                                regsubkey_ctr_specific_key(ctr, i));
     562                        if (thistime2 != thistime) {
     563                                DEBUG(0, ("tdb_pack failed\n"));
     564                                ret = false;
     565                                goto done;
     566                        }
     567                }
     568                len += thistime;
    554569        }
    555570
     
    928943int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
    929944{
    930         WERROR werr;
    931945        uint32 num_items;
    932946        uint8 *buf;
     
    959973        len = tdb_unpack( buf, buflen, "d", &num_items);
    960974
     975        /*
     976         * The following code breaks the abstraction that reg_objects.c sets
     977         * up with regsubkey_ctr_addkey(). But if we use that with the current
     978         * data structure of ctr->subkeys being an unsorted array, we end up
     979         * with an O(n^2) algorithm for retrieving keys from the tdb
     980         * file. This is pretty pointless, as we have to trust the data
     981         * structure on disk not to have duplicates anyway. The alternative to
     982         * breaking this abstraction would be to set up a more sophisticated
     983         * data structure in REGSUBKEY_CTR.
     984         *
     985         * This makes "net conf list" for a registry with >1000 shares
     986         * actually usable :-)
     987         */
     988
     989        ctr->subkeys = talloc_array(ctr, char *, num_items);
     990        if (ctr->subkeys == NULL) {
     991                DEBUG(5, ("regdb_fetch_keys: could not allocate subkeys\n"));
     992                goto done;
     993        }
     994        ctr->num_subkeys = num_items;
     995
    961996        for (i=0; i<num_items; i++) {
    962997                len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
    963                 werr = regsubkey_ctr_addkey(ctr, subkeyname);
    964                 if (!W_ERROR_IS_OK(werr)) {
    965                         DEBUG(5, ("regdb_fetch_keys: regsubkey_ctr_addkey "
    966                                   "failed: %s\n", dos_errstr(werr)));
     998                ctr->subkeys[i] = talloc_strdup(ctr->subkeys, subkeyname);
     999                if (ctr->subkeys[i] == NULL) {
     1000                        DEBUG(5, ("regdb_fetch_keys: could not allocate "
     1001                                  "subkeyname\n"));
     1002                        TALLOC_FREE(ctr->subkeys);
     1003                        ctr->num_subkeys = 0;
    9671004                        goto done;
    9681005                }
  • branches/samba-3.3.x/source/registry/reg_dispatcher.c

    r206 r221  
    4040        size_t i = 0;
    4141        SEC_DESC *sd;
    42         SEC_ACL *acl;
     42        SEC_ACL *theacl;
    4343        size_t sd_size;
    4444
     
    6060        /* create the security descriptor */
    6161
    62         acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace);
    63         if (acl == NULL) {
     62        theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace);
     63        if (theacl == NULL) {
    6464                return WERR_NOMEM;
    6565        }
     
    6767        sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,
    6868                           &global_sid_Builtin_Administrators,
    69                            &global_sid_System, NULL, acl,
     69                           &global_sid_System, NULL, theacl,
    7070                           &sd_size);
    7171        if (sd == NULL) {
Note: See TracChangeset for help on using the changeset viewer.