From 1c4c4dd7e044f20c3de623b189a5c0d65b0a67b4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 8 Apr 2010 16:09:36 +0200 Subject: s4-smbtorture: protect against full UNC paths in winreg printerinfo test. Guenther --- source4/torture/rpc/spoolss.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 9a647f76c1..1f6153c1c4 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -3843,6 +3843,26 @@ static bool test_GetForm_winreg(struct torture_context *tctx, return true; } +static const char *strip_unc(const char *unc) +{ + char *name; + + if (!unc) { + return NULL; + } + + if (unc[0] == '\\' && unc[1] == '\\') { + unc +=2; + } + + name = strchr(unc, '\\'); + if (name) { + return name+1; + } + + return unc; +} + static bool test_GetPrinterInfo_winreg(struct torture_context *tctx, struct dcerpc_binding_handle *b, struct policy_handle *handle, @@ -3856,6 +3876,7 @@ static bool test_GetPrinterInfo_winreg(struct torture_context *tctx, TOP_LEVEL_PRINT_PRINTERS_KEY }; int i; + const char *printername, *sharename; torture_comment(tctx, "Testing Printer Info and winreg consistency\n"); @@ -3863,6 +3884,9 @@ static bool test_GetPrinterInfo_winreg(struct torture_context *tctx, test_GetPrinter_level(tctx, b, handle, 2, &info), "failed to get printer info level 2"); + printername = strip_unc(info.info2.printername); + sharename = strip_unc(info.info2.sharename); + #define test_sz(key, wname, iname) \ do {\ DATA_BLOB blob;\ @@ -3960,8 +3984,8 @@ do {\ torture_assert(tctx, test_winreg_OpenKey(tctx, winreg_handle, hive_handle, printer_key, &key_handle), ""); - test_sz(keys[i], "Name", info.info2.printername); - test_sz(keys[i], "Share Name", info.info2.sharename); + test_sz(keys[i], "Name", printername); + test_sz(keys[i], "Share Name", sharename); test_sz(keys[i], "Port", info.info2.portname); test_sz(keys[i], "Printer Driver", info.info2.drivername); test_sz(keys[i], "Description", info.info2.comment); -- cgit