From 4a48148a7d830fb0ec6884f39b2ab1e5d41f2181 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 30 Apr 2024 17:31:00 +0200 Subject: [PATCH] s4:torture: Add missing NULL checks in spoolss.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit source4/torture/rpc/spoolss.c: In function ‘check_printer_driver_file.isra’: source4/torture/rpc/spoolss.c:10850:58: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 10850 | const char *remote_name = talloc_asprintf(tctx, "%s\\%d\\%s", | ^~ Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- source4/torture/rpc/spoolss.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 05a0aef7e43..867b94ba654 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -10846,15 +10846,22 @@ static bool check_printer_driver_file(struct torture_context *tctx, struct torture_driver_context *d, const char *file_name) { - const char *remote_arch_dir = driver_directory_dir(d->remote.driver_directory); - const char *remote_name = talloc_asprintf(tctx, "%s\\%d\\%s", - remote_arch_dir, - d->info8.version, - file_name); + const char *remote_arch_dir = NULL; + const char *remote_name = NULL; int fnum; torture_assert(tctx, (file_name && strlen(file_name) != 0), "invalid filename"); + remote_arch_dir = driver_directory_dir(d->remote.driver_directory); + torture_assert_not_null(tctx, remote_arch_dir, "remote_arch_dir is null"); + + remote_name = talloc_asprintf(tctx, + "%s\\%d\\%s", + remote_arch_dir, + d->info8.version, + file_name); + torture_assert_not_null(tctx, remote_name, "renote_name is null"); + torture_comment(tctx, "checking for driver file at %s\n", remote_name); fnum = smbcli_open(cli->tree, remote_name, O_RDONLY, DENY_NONE);