From 2f6776741dc6469d78b94da22d75f26cccca5fc9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 19 Jan 2023 12:22:33 +0100 Subject: [PATCH] smbd: Move smbXsrv_open_global_parse_record() up in smbXsrv_open.c Avoid a prototype in the next patches Signed-off-by: Volker Lendecke --- source3/smbd/smbXsrv_open.c | 99 +++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/source3/smbd/smbXsrv_open.c b/source3/smbd/smbXsrv_open.c index 1e1423fa0cb..1edd5635033 100644 --- a/source3/smbd/smbXsrv_open.c +++ b/source3/smbd/smbXsrv_open.c @@ -321,6 +321,56 @@ static NTSTATUS smbXsrv_open_global_allocate( return NT_STATUS_INTERNAL_ERROR; } +static NTSTATUS smbXsrv_open_global_parse_record( + TALLOC_CTX *mem_ctx, + struct db_record *rec, + struct smbXsrv_open_global0 **global) +{ + TDB_DATA key = dbwrap_record_get_key(rec); + TDB_DATA val = dbwrap_record_get_value(rec); + DATA_BLOB blob = data_blob_const(val.dptr, val.dsize); + struct smbXsrv_open_globalB global_blob; + enum ndr_err_code ndr_err; + NTSTATUS status; + TALLOC_CTX *frame = talloc_stackframe(); + + ndr_err = ndr_pull_struct_blob(&blob, frame, &global_blob, + (ndr_pull_flags_fn_t)ndr_pull_smbXsrv_open_globalB); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:" + "key '%s' ndr_pull_struct_blob - %s\n", + tdb_data_dbg(key), + ndr_errstr(ndr_err))); + status = ndr_map_error2ntstatus(ndr_err); + goto done; + } + + if (global_blob.version != SMBXSRV_VERSION_0) { + status = NT_STATUS_INTERNAL_DB_CORRUPTION; + DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:" + "key '%s' unsupported version - %d - %s\n", + tdb_data_dbg(key), + (int)global_blob.version, + nt_errstr(status))); + goto done; + } + + if (global_blob.info.info0 == NULL) { + status = NT_STATUS_INTERNAL_DB_CORRUPTION; + DEBUG(1,("Invalid record in smbXsrv_tcon_global.tdb:" + "key '%s' info0 NULL pointer - %s\n", + tdb_data_dbg(key), + nt_errstr(status))); + goto done; + } + + *global = talloc_move(mem_ctx, &global_blob.info.info0); + status = NT_STATUS_OK; +done: + talloc_free(frame); + return status; +} + static NTSTATUS smbXsrv_open_global_verify_record( TDB_DATA key, TDB_DATA val, @@ -1265,55 +1315,6 @@ NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn, } -static NTSTATUS smbXsrv_open_global_parse_record(TALLOC_CTX *mem_ctx, - struct db_record *rec, - struct smbXsrv_open_global0 **global) -{ - TDB_DATA key = dbwrap_record_get_key(rec); - TDB_DATA val = dbwrap_record_get_value(rec); - DATA_BLOB blob = data_blob_const(val.dptr, val.dsize); - struct smbXsrv_open_globalB global_blob; - enum ndr_err_code ndr_err; - NTSTATUS status; - TALLOC_CTX *frame = talloc_stackframe(); - - ndr_err = ndr_pull_struct_blob(&blob, frame, &global_blob, - (ndr_pull_flags_fn_t)ndr_pull_smbXsrv_open_globalB); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:" - "key '%s' ndr_pull_struct_blob - %s\n", - tdb_data_dbg(key), - ndr_errstr(ndr_err))); - status = ndr_map_error2ntstatus(ndr_err); - goto done; - } - - if (global_blob.version != SMBXSRV_VERSION_0) { - status = NT_STATUS_INTERNAL_DB_CORRUPTION; - DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:" - "key '%s' unsupported version - %d - %s\n", - tdb_data_dbg(key), - (int)global_blob.version, - nt_errstr(status))); - goto done; - } - - if (global_blob.info.info0 == NULL) { - status = NT_STATUS_INTERNAL_DB_CORRUPTION; - DEBUG(1,("Invalid record in smbXsrv_tcon_global.tdb:" - "key '%s' info0 NULL pointer - %s\n", - tdb_data_dbg(key), - nt_errstr(status))); - goto done; - } - - *global = talloc_move(mem_ctx, &global_blob.info.info0); - status = NT_STATUS_OK; -done: - talloc_free(frame); - return status; -} - struct smbXsrv_open_global_traverse_state { int (*fn)(struct smbXsrv_open_global0 *, void *); void *private_data; -- 2.11.4.GIT