1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

net_registry: don't leak state_path onto talloc tos

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
David Disseldorp 2014-11-02 20:21:33 +01:00 committed by Jeremy Allison
parent 70896833c9
commit c3f3b13beb

View File

@ -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;
}