diff options
author | David Disseldorp <ddiss@samba.org> | 2014-11-02 20:21:49 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-11-04 02:07:35 +0100 |
commit | e07ecd4fe698f685299258a666127430a3952058 (patch) | |
tree | 3ca5b2f5f0b5dbaba574856d1b841031f90fe899 | |
parent | c5e241831c4d62ca9571fe3bec1434ecbf3e706c (diff) | |
download | samba-e07ecd4fe698f685299258a666127430a3952058.tar.gz |
smbstatus: check for lock_path talloc failures
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Nov 4 02:07:35 CET 2014 on sn-devel-104
-rw-r--r-- | source3/utils/status.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source3/utils/status.c b/source3/utils/status.c index b58981329b9..936e87b7425 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -365,6 +365,7 @@ int main(int argc, const char *argv[]) TALLOC_CTX *frame = talloc_stackframe(); int ret = 0; struct messaging_context *msg_ctx; + char *db_path; sec_init(); load_case_tables(); @@ -486,7 +487,14 @@ int main(int argc, const char *argv[]) if ( show_shares ) { if (verbose) { - d_printf("Opened %s\n", lock_path("connections.tdb")); + db_path = lock_path("connections.tdb"); + if (db_path == NULL) { + d_printf("Out of memory - exiting\n"); + ret = -1; + goto done; + } + d_printf("Opened %s\n", db_path); + TALLOC_FREE(db_path); } if (brief) { @@ -508,18 +516,27 @@ int main(int argc, const char *argv[]) if ( show_locks ) { int result; struct db_context *db; - db = db_open(NULL, lock_path("locking.tdb"), 0, + + db_path = lock_path("locking.tdb"); + if (db_path == NULL) { + d_printf("Out of memory - exiting\n"); + ret = -1; + goto done; + } + + db = db_open(NULL, db_path, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); if (!db) { - d_printf("%s not initialised\n", - lock_path("locking.tdb")); + d_printf("%s not initialised\n", db_path); d_printf("This is normal if an SMB client has never " "connected to your server.\n"); + TALLOC_FREE(db_path); exit(0); } else { TALLOC_FREE(db); + TALLOC_FREE(db_path); } if (!locking_init_readonly()) { |