mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s4:samdb: Avoid memory leaks in partition_metadata_get_uint64()
==395==ERROR: LeakSanitizer: detected memory leaks Direct leak of 96 byte(s) in 1 object(s) allocated from: #0 0x7f4c5dedc03f in malloc (/lib64/libasan.so.8+0xdc03f) (BuildId: b10bafa0ba3304197db35cc24e0024cb0492168a) #1 0x7f4c5d252b3e in __talloc_with_prefix ../../lib/talloc/talloc.c:783 #2 0x7f4c5d2543cc in __talloc ../../lib/talloc/talloc.c:825 #3 0x7f4c5d2543cc in _talloc_named_const ../../lib/talloc/talloc.c:982 #4 0x7f4c5d2543cc in talloc_named_const ../../lib/talloc/talloc.c:1751 #5 0x7f4c504acc53 in partition_metadata_get_uint64 ../../source4/dsdb/samdb/ldb_modules/partition_metadata.c:50 #6 0x7f4c504add29 in partition_metadata_sequence_number_increment ../../source4/dsdb/samdb/ldb_modules/partition_metadata.c:398 #7 0x7f4c504a66aa in partition_sequence_number ../../source4/dsdb/samdb/ldb_modules/partition.c:1401 #8 0x7f4c504a66aa in partition_extended ../../source4/dsdb/samdb/ldb_modules/partition.c:1680 #9 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #10 0x7f4c503980c8 in replmd_extended ../../source4/dsdb/samdb/ldb_modules/repl_meta_data.c:8455 #11 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #12 0x7f4c502fae5c in samldb_extended ../../source4/dsdb/samdb/ldb_modules/samldb.c:5718 #13 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #14 0x7f4c52f0b94c in acl_extended ../../source4/dsdb/samdb/ldb_modules/acl.c:2854 #15 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #16 0x7f4c52eb019c in descriptor_extended ../../source4/dsdb/samdb/ldb_modules/descriptor.c:1450 #17 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #18 0x7f4c52ed8687 in log_extended ../../source4/dsdb/samdb/ldb_modules/audit_log.c:1824 #19 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #20 0x7f4c505aa337 in unlazy_op ../../source4/dsdb/samdb/ldb_modules/lazy_commit.c:40 #21 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #22 0x7f4c502d0f82 in schema_load_extended ../../source4/dsdb/samdb/ldb_modules/schema_load.c:593 #23 0x7f4c5c498c44 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:559 #24 0x7f4c5035a010 in rootdse_extended ../../source4/dsdb/samdb/ldb_modules/rootdse.c:1780 #25 0x7f4c5c4914ef in ldb_request ../../lib/ldb/common/ldb.c:1244 #26 0x7f4c5c492a2d in ldb_extended ../../lib/ldb/common/ldb.c:1714 #27 0x7f4c5c492bdf in ldb_sequence_number ../../lib/ldb/common/ldb.c:1943 #28 0x7f4c503a9abd in replmd_add ../../source4/dsdb/samdb/ldb_modules/repl_meta_data.c:1316 #29 0x7f4c5c4989f4 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:543 #30 0x7f4c50458783 in rdn_name_add ../../lib/ldb/modules/rdn_name.c:206 #31 0x7f4c5c4989f4 in ldb_next_request ../../lib/ldb/common/ldb_modules.c:543 #32 0x7f4c504f4852 in attr_handler ../../source4/dsdb/samdb/ldb_modules/objectclass_attrs.c:334 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
This commit is contained in:
parent
3fc3582756
commit
a420aa919c
@ -36,7 +36,6 @@ static int partition_metadata_get_uint64(struct ldb_module *module,
|
||||
struct tdb_context *tdb;
|
||||
TDB_DATA tdb_key, tdb_data;
|
||||
char *value_str;
|
||||
TALLOC_CTX *tmp_ctx;
|
||||
int error = 0;
|
||||
|
||||
data = talloc_get_type_abort(ldb_module_get_private(module),
|
||||
@ -47,11 +46,6 @@ static int partition_metadata_get_uint64(struct ldb_module *module,
|
||||
"partition_metadata: metadata tdb not initialized");
|
||||
}
|
||||
|
||||
tmp_ctx = talloc_new(NULL);
|
||||
if (tmp_ctx == NULL) {
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
|
||||
tdb = data->metadata->db->tdb;
|
||||
|
||||
tdb_key.dptr = (uint8_t *)discard_const_p(char, key);
|
||||
@ -68,22 +62,19 @@ static int partition_metadata_get_uint64(struct ldb_module *module,
|
||||
}
|
||||
}
|
||||
|
||||
value_str = talloc_strndup(tmp_ctx, (char *)tdb_data.dptr, tdb_data.dsize);
|
||||
value_str = talloc_strndup(NULL, (char *)tdb_data.dptr, tdb_data.dsize);
|
||||
SAFE_FREE(tdb_data.dptr);
|
||||
if (value_str == NULL) {
|
||||
SAFE_FREE(tdb_data.dptr);
|
||||
talloc_free(tmp_ctx);
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
|
||||
*value = smb_strtoull(value_str, NULL, 10, &error, SMB_STR_STANDARD);
|
||||
talloc_free(value_str);
|
||||
if (error != 0) {
|
||||
return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
|
||||
"partition_metadata: converision failed");
|
||||
}
|
||||
|
||||
SAFE_FREE(tdb_data.dptr);
|
||||
talloc_free(tmp_ctx);
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user