From c3f3b13bebcbe10baf805a1b1ad3386e59a532ba Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Sun, 2 Nov 2014 20:21:33 +0100 Subject: [PATCH] net_registry: don't leak state_path onto talloc tos Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source3/utils/net_registry.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index 0993b958b18..befc73c4e40 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -1484,8 +1484,9 @@ static int net_registry_convert(struct net_context *c, int argc, static int net_registry_check(struct net_context *c, int argc, const char **argv) { - const char *dbfile; + char *dbfile; struct check_options opts; + int ret; if (argc > 1|| c->display_usage) { d_printf("%s\n%s", @@ -1505,9 +1506,13 @@ static int net_registry_check(struct net_context *c, int argc, return c->display_usage ? 0 : -1; } - dbfile = c->opt_db ? c->opt_db : ( - (argc > 0) ? argv[0] : - state_path("registry.tdb")); + if (c->opt_db != NULL) { + dbfile = talloc_strdup(talloc_tos(), c->opt_db); + } else if (argc > 0) { + dbfile = talloc_strdup(talloc_tos(), argv[0]); + } else { + dbfile = state_path("registry.tdb"); + } if (dbfile == NULL) { return -1; } @@ -1525,7 +1530,9 @@ static int net_registry_check(struct net_context *c, int argc, .implicit_db = (c->opt_db == NULL) && (argc == 0), }; - return net_registry_check_db(dbfile, &opts); + ret = net_registry_check_db(dbfile, &opts); + talloc_free(dbfile); + return ret; }