Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
NTSTATUS smbXsrv_open_global_init(void)
{
- const char *global_path = NULL;
+ char *global_path = NULL;
struct db_context *db_ctx = NULL;
if (smbXsrv_open_global_db_ctx != NULL) {
}
global_path = lock_path("smbXsrv_open_global.tdb");
+ if (global_path == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
db_ctx = db_open(NULL, global_path,
0, /* hash_size */
O_RDWR | O_CREAT, 0600,
DBWRAP_LOCK_ORDER_1,
DBWRAP_FLAG_NONE);
+ TALLOC_FREE(global_path);
if (db_ctx == NULL) {
NTSTATUS status;
NTSTATUS smbXsrv_session_global_init(void)
{
- const char *global_path = NULL;
+ char *global_path = NULL;
struct db_context *db_ctx = NULL;
if (smbXsrv_session_global_db_ctx != NULL) {
* This contains secret information like session keys!
*/
global_path = lock_path("smbXsrv_session_global.tdb");
+ if (global_path == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
db_ctx = db_open(NULL, global_path,
0, /* hash_size */
O_RDWR | O_CREAT, 0600,
DBWRAP_LOCK_ORDER_1,
DBWRAP_FLAG_NONE);
+ TALLOC_FREE(global_path);
if (db_ctx == NULL) {
NTSTATUS status;
NTSTATUS smbXsrv_tcon_global_init(void)
{
- const char *global_path = NULL;
+ char *global_path = NULL;
struct db_context *db_ctx = NULL;
if (smbXsrv_tcon_global_db_ctx != NULL) {
}
global_path = lock_path("smbXsrv_tcon_global.tdb");
+ if (global_path == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
db_ctx = db_open(NULL, global_path,
0, /* hash_size */
O_RDWR | O_CREAT, 0600,
DBWRAP_LOCK_ORDER_1,
DBWRAP_FLAG_NONE);
+ TALLOC_FREE(global_path);
if (db_ctx == NULL) {
NTSTATUS status;
frame = talloc_stackframe();
global_path = lock_path("smbXsrv_version_global.tdb");
+ if (global_path == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
db_ctx = db_open(NULL, global_path,
0, /* hash_size */