diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-05-24 17:40:27 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2018-06-14 20:52:22 +0200 |
commit | bad43d31316fccd53ccc7671294903cc9c30bd0c (patch) | |
tree | 275d3578a8e443c192a8c09314c68555880b698b /source3/printing | |
parent | 7d493eaeb11e1652cb1e4d59b3aceb2e33fae400 (diff) | |
download | samba-bad43d31316fccd53ccc7671294903cc9c30bd0c.tar.gz |
printing: add an explicit talloc_stackframe() to get_correct_cversion()
This makes further changes simpler.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/nt_printing.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 52bba6fcb3d..5c448800926 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -986,6 +986,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf const char *driver_directory, WERROR *perr) { + TALLOC_CTX *frame = talloc_stackframe(); int cversion = -1; NTSTATUS nt_status; struct smb_filename *smb_fname = NULL; @@ -1003,6 +1004,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf if (strcmp(architecture, SPL_ARCH_WIN40) == 0) { DEBUG(10,("get_correct_cversion: Driver is Win9x, cversion = 0\n")); *perr = WERR_OK; + TALLOC_FREE(frame); return 0; } @@ -1010,26 +1012,30 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf if (strcmp(architecture, SPL_ARCH_X64) == 0) { DEBUG(10,("get_correct_cversion: Driver is x64, cversion = 3\n")); *perr = WERR_OK; + TALLOC_FREE(frame); return 3; } - printdollar_snum = find_service(talloc_tos(), "print$", &printdollar); + printdollar_snum = find_service(frame, "print$", &printdollar); if (!printdollar) { *perr = WERR_NOT_ENOUGH_MEMORY; + TALLOC_FREE(frame); return -1; } if (printdollar_snum == -1) { *perr = WERR_BAD_NET_NAME; + TALLOC_FREE(frame); return -1; } - printdollar_path = lp_path(talloc_tos(), printdollar_snum); + printdollar_path = lp_path(frame, printdollar_snum); if (printdollar_path == NULL) { *perr = WERR_NOT_ENOUGH_MEMORY; + TALLOC_FREE(frame); return -1; } - working_dir = talloc_asprintf(talloc_tos(), + working_dir = talloc_asprintf(frame, "%s/%s", printdollar_path, architecture); @@ -1038,13 +1044,13 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf * directory, switch to the driver directory. */ if (driver_directory != NULL) { - working_dir = talloc_asprintf(talloc_tos(), "%s/%s/%s", + working_dir = talloc_asprintf(frame, "%s/%s/%s", printdollar_path, architecture, driver_directory); } - nt_status = create_conn_struct_cwd(talloc_tos(), + nt_status = create_conn_struct_cwd(frame, server_event_context(), server_messaging_context(), &conn, @@ -1055,6 +1061,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf DEBUG(0,("get_correct_cversion: create_conn_struct " "returned %s\n", nt_errstr(nt_status))); *perr = ntstatus_to_werror(nt_status); + TALLOC_FREE(frame); return -1; } @@ -1163,13 +1170,11 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf error_exit: unbecome_user(); error_free_conn: - TALLOC_FREE(smb_fname); if (fsp != NULL) { close_file(NULL, fsp, NORMAL_CLOSE); } if (conn != NULL) { vfs_ChDir(conn, oldcwd_fname); - TALLOC_FREE(oldcwd_fname); SMB_VFS_DISCONNECT(conn); conn_free(conn); } @@ -1177,6 +1182,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf cversion = -1; } + TALLOC_FREE(frame); return cversion; } |