summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-04-08 16:09:36 +0200
committerGünther Deschner <gd@samba.org>2010-04-08 16:14:20 +0200
commit1c4c4dd7e044f20c3de623b189a5c0d65b0a67b4 (patch)
treef84b48ded9bd68a119e10d76357e3ca493eb5e7f
parentef3490e79959a3c4366f6981c67dbe5e529a3738 (diff)
downloadsamba-1c4c4dd7e044f20c3de623b189a5c0d65b0a67b4.tar.gz
samba-1c4c4dd7e044f20c3de623b189a5c0d65b0a67b4.tar.bz2
samba-1c4c4dd7e044f20c3de623b189a5c0d65b0a67b4.zip
s4-smbtorture: protect against full UNC paths in winreg printerinfo test.
Guenther
-rw-r--r--source4/torture/rpc/spoolss.c28
1 files 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);