r18344: add a test to show hoe NetNameValidate behaves.
authorSimo Sorce <idra@samba.org>
Sun, 10 Sep 2006 21:51:46 +0000 (21:51 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:13 +0000 (14:18 -0500)
fix the misleading idl names
(This used to be commit 8367b3bcee9338fa3e268b7342ae8db928008b55)

source4/librpc/idl/srvsvc.idl
source4/torture/rpc/srvsvc.c

index 8cd9d63864d189f1fc7a0fc0712684ba4d743deb..4f1f70c6e8fc53cd9dc6b817e38b0ad33934d384 100644 (file)
        /* Function: 0x21 */
        WERROR srvsvc_NetNameValidate(
                [in]   [string,charset(UTF16)] uint16 *server_unc,
-               [in]   [string,charset(UTF16)] uint16 path[],
-               [in]    uint32 pathtype,
-               [in]    uint32 pathflags
+               [in]   [string,charset(UTF16)] uint16 name[],
+               [in]    uint32 name_type,
+               [in]    uint32 flags
                );
 
        /******************/
        /* Function: 0x23 */
        WERROR srvsvc_NetPRNameCompare(
                [in]   [string,charset(UTF16)] uint16 *server_unc,
-               [in]   [string,charset(UTF16)] uint16 path1[],
-               [in]   [string,charset(UTF16)] uint16 path2[],
-               [in]    uint32 pathtype,
-               [in]    uint32 pathflags
+               [in]   [string,charset(UTF16)] uint16 name1[],
+               [in]   [string,charset(UTF16)] uint16 name2[],
+               [in]    uint32 name_type,
+               [in]    uint32 flags
                );
 
 /**************************/
index dc48516b918b7d15ae3edec9c98ab3dac9af0326..78bde03dede3d7362f0a23efac9b83b0b9869b31 100644 (file)
@@ -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) {