r11457: fixed the winreg IDL and torture code so key and value enumerations
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Nov 2005 01:01:17 +0000 (01:01 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:45:39 +0000 (13:45 -0500)
work again. The automatic value() is fine for the length, but cannot
be used for the size as the size is not the number of bytes being
sent, but the number of bytes that the server is allowed to use in the
reply

source/librpc/idl/winreg.idl
source/torture/rpc/winreg.c

index 83a95ebac4a4915b07fbceb0f504afb78ac8fe3a..d0da5fcc24846a47b23cc7a7384df987f4fed0d8 100644 (file)
 
        typedef struct {
                [value(strlen_m(name)*2)] uint16 length; 
-               [value(strlen_m(name)*2)] uint16 size;
+               /* size cannot be auto-set by value() as it is the
+                  amount of space the server is allowed to use for this
+                  string in the reply, not its current size */
+               uint16 size;
                [size_is(size/2),length_is(length/2),charset(UTF16)] uint16 *name;
        } winreg_StringBuf;
 
index 873ad10a2332adb0d716f8b43ce8ead659a31b42..cfcb91cafb6e6376d46c6995e748b797adf314b1 100644 (file)
@@ -403,6 +403,7 @@ static BOOL test_EnumKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        printf("Testing EnumKey\n\n");
 
        class.name   = "";
+       class.size   = 1024;
 
        r.in.handle = handle;
        r.in.enum_index = 0;
@@ -413,6 +414,7 @@ static BOOL test_EnumKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 
        do {
                name.name   = NULL;
+               name.size   = 1024;
 
                status = dcerpc_winreg_EnumKey(p, mem_ctx, &r);
 
@@ -533,6 +535,7 @@ static BOOL test_EnumValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        printf("testing EnumValue\n");
 
        name.name   = "";
+       name.size   = 1024;
 
        r.in.handle = handle;
        r.in.enum_index = 0;
@@ -684,7 +687,7 @@ static BOOL test_Open(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                      const char *name, winreg_open_fn open_fn)
 {
        struct policy_handle handle, newhandle;
-       BOOL ret = True, created = False, deleted = False;
+       BOOL ret = True, created = False, created2 = False, deleted = False;
        struct winreg_OpenHKLM r;
        NTSTATUS status;
 
@@ -742,20 +745,17 @@ static BOOL test_Open(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                ret = False;
        }
 
-       if (created && !test_CreateKey_sd(p, mem_ctx, &handle, TEST_KEY2, 
+       if (created && test_CreateKey_sd(p, mem_ctx, &handle, TEST_KEY2, 
                                          NULL, &newhandle)) {
-               printf("CreateKey failed - not considering a failure\n");
-               created = False;
-       } else {
-               created = True;
+               created2 = True;
        }
 
-       if (created && !test_GetKeySecurity(p, mem_ctx, &newhandle)) {
+       if (created2 && !test_GetKeySecurity(p, mem_ctx, &newhandle)) {
                printf("GetKeySecurity failed\n");
                ret = False;
        }
 
-       if (created && !test_CloseKey(p, mem_ctx, &newhandle)) {
+       if (created2 && !test_CloseKey(p, mem_ctx, &newhandle)) {
                printf("CloseKey failed\n");
                ret = False;
        }