Changeset 221 for branches/samba-3.3.x/source/registry
- Timestamp:
- May 24, 2009, 7:17:10 AM (16 years ago)
- 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 537 537 538 538 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); 544 551 if(buffer == NULL) { 545 552 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)); 547 555 ret = false; 548 556 goto done; 549 557 } 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; 554 569 } 555 570 … … 928 943 int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr) 929 944 { 930 WERROR werr;931 945 uint32 num_items; 932 946 uint8 *buf; … … 959 973 len = tdb_unpack( buf, buflen, "d", &num_items); 960 974 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 961 996 for (i=0; i<num_items; i++) { 962 997 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; 967 1004 goto done; 968 1005 } -
branches/samba-3.3.x/source/registry/reg_dispatcher.c
r206 r221 40 40 size_t i = 0; 41 41 SEC_DESC *sd; 42 SEC_ACL * acl;42 SEC_ACL *theacl; 43 43 size_t sd_size; 44 44 … … 60 60 /* create the security descriptor */ 61 61 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) { 64 64 return WERR_NOMEM; 65 65 } … … 67 67 sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, 68 68 &global_sid_Builtin_Administrators, 69 &global_sid_System, NULL, acl,69 &global_sid_System, NULL, theacl, 70 70 &sd_size); 71 71 if (sd == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.