summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-09-10 21:51:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:13 -0500
commit8f107700a5a4201aeda7fcb27b427aab91a069ff (patch)
treed2798c0677fb79a06cb89d62c60295a2efdcdb1b /source4/torture/rpc
parenta8421e81078b91ae97ada3be352416eae26a9c7b (diff)
downloadsamba-8f107700a5a4201aeda7fcb27b427aab91a069ff.tar.gz
samba-8f107700a5a4201aeda7fcb27b427aab91a069ff.tar.bz2
samba-8f107700a5a4201aeda7fcb27b427aab91a069ff.zip
r18344: add a test to show hoe NetNameValidate behaves.
fix the misleading idl names (This used to be commit 8367b3bcee9338fa3e268b7342ae8db928008b55)
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/srvsvc.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index dc48516b91..78bde03ded 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -766,6 +766,78 @@ static BOOL test_NetRemoteTOD(struct dcerpc_pipe *p,
return ret;
}
+/**************************/
+/* srvsvc_NetName */
+/**************************/
+
+static BOOL test_NetNameValidate(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ struct srvsvc_NetNameValidate r;
+ char *invalidc;
+ int i, n;
+
+ r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.flags = 0x0;
+
+ printf("testing NetNameValidate\n");
+
+ /* valid path types only between 1 and 13 */
+ for (i = 1; i < 14; i++) {
+
+ /* Find maximum length accepted by this type */
+ r.in.name_type = i;
+ r.in.name = talloc_strdup(mem_ctx, "A");
+ n = 0;
+
+ while (W_ERROR_IS_OK(r.out.result)) {
+ status = dcerpc_srvsvc_NetNameValidate(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("NetNameValidate failed while checking maximum size (%s)\n",
+ nt_errstr(status));
+ break;
+ }
+
+ r.in.name = talloc_append_string(mem_ctx, r.in.name, "A");
+ if (!r.in.name) {
+ printf("NetNameValidate: Out of memory!\n");
+ return False;
+ }
+ n++;
+ }
+
+ talloc_free(r.in.name);
+
+ printf("Maximum length for type %d: %d\n", i, n);
+
+ /* find invalid chars for this type check only ASCII between 0x20 and 0x7e */
+
+ invalidc = NULL;
+
+ for (n = 0x20; n < 0x7e; n++) {
+ r.in.name = talloc_asprintf(mem_ctx, "%c", (char)n);
+
+ status = dcerpc_srvsvc_NetNameValidate(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("NetNameValidate failed while checking valid chars (%s)\n",
+ nt_errstr(status));
+ break;
+ }
+
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ invalidc = talloc_asprintf_append(invalidc, "%c", (char)n);
+ }
+
+ talloc_free(r.in.name);
+ }
+
+ printf("Invalid chars for type %d: %s\n", i, invalidc);
+ }
+
+ return True;
+}
+
BOOL torture_rpc_srvsvc(struct torture_context *torture)
{
NTSTATUS status;
@@ -795,7 +867,8 @@ BOOL torture_rpc_srvsvc(struct torture_context *torture)
ret &= test_NetRemoteTOD(p, mem_ctx);
ret &= test_NetShareEnum(p, mem_ctx, True);
ret &= test_NetShareGetInfo(p, mem_ctx, "ADMIN$", True);
-
+ ret &= test_NetNameValidate(p, mem_ctx);
+
status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_srvsvc);
if (!binding) {