summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:47 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:05 +0100
commitca18783463d2f49a4249b0774196caafd4a08a22 (patch)
tree20a1854d4c7ab8db3855f1d8bdf85e0b325c8d86 /source3
parentd3cd60d660a4a8ef03689c0b66ed730e444f84cc (diff)
downloadsamba-ca18783463d2f49a4249b0774196caafd4a08a22.tar.gz
samba-ca18783463d2f49a4249b0774196caafd4a08a22.tar.xz
samba-ca18783463d2f49a4249b0774196caafd4a08a22.zip
notify_internal: don't leak lock_path onto talloc tos
Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/notify_internal.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c
index 2ba68d74bc..4e9862ac65 100644
--- a/source3/smbd/notify_internal.c
+++ b/source3/smbd/notify_internal.c
@@ -125,6 +125,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
{
struct loadparm_context *lp_ctx;
struct notify_context *notify;
+ char *db_path;
notify = talloc(mem_ctx, struct notify_context);
if (notify == NULL) {
@@ -134,18 +135,32 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
notify->list = NULL;
lp_ctx = loadparm_init_s3(notify, loadparm_s3_helpers());
+
+ db_path = lock_path("notify.tdb");
+ if (db_path == NULL) {
+ goto fail;
+ }
+
notify->db_notify = db_open_tdb(
- notify, lp_ctx, lock_path("notify.tdb"),
+ notify, lp_ctx, db_path,
0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE);
- talloc_unlink(notify, lp_ctx);
+ talloc_unlink(notify, lp_ctx);
+ TALLOC_FREE(db_path);
if (notify->db_notify == NULL) {
goto fail;
}
+
+ db_path = lock_path("notify_index.tdb");
+ if (db_path == NULL) {
+ goto fail;
+ }
+
notify->db_index = db_open(
- notify, lock_path("notify_index.tdb"),
+ notify, db_path,
0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_3, DBWRAP_FLAG_NONE);
+ TALLOC_FREE(db_path);
if (notify->db_index == NULL) {
goto fail;
}