r19811: Decode REG_MULTI_SZ and REG_BINARY
authorVolker Lendecke <vlendec@samba.org>
Tue, 21 Nov 2006 02:21:45 +0000 (02:21 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:15:57 +0000 (12:15 -0500)
(This used to be commit 679330175185f8504bb5968339dcc7cb20d9140c)

source3/include/reg_objects.h
source3/lib/util_reg.c
source3/rpcclient/cmd_spoolss.c
source3/utils/net_rpc_printer.c
source3/utils/net_rpc_registry.c

index 6ddbb89cc750ac79e4d7c52b3858e88147c102ee..99da22f8cd7b7f33df7788129df1d96d24b4c8ae 100644 (file)
@@ -33,9 +33,9 @@ typedef struct {
 } REGISTRY_VALUE;
 
 /*
- * A registry string is not necessarily NULL terminated. When retrieving it
- * from the net, we guarantee this however. A server might want to push it
- * without the terminator though.
+ * A REG_SZ string is not necessarily NULL terminated. When retrieving it from
+ * the net, we guarantee this however. A server might want to push it without
+ * the terminator though.
  */
 
 struct registry_string {
@@ -51,7 +51,7 @@ struct registry_value {
                struct registry_string sz;
                struct {
                        uint32 num_strings;
-                       struct registry_string *strings;
+                       char **strings;
                } multi_sz;
                DATA_BLOB binary;
        } v;
index 80b52924b67792712e01c4f5e80ac4d4d6ea182c..c74a57314974222ce601bda7ffb0f6c6a8508b38 100644 (file)
@@ -69,7 +69,7 @@ const char *reg_type_lookup(uint32 type)
 }
 
 NTSTATUS reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
-                          int *num_values, char ***values)
+                          uint32 *num_values, char ***values)
 {
        const smb_ucs2_t *p = (const smb_ucs2_t *)buf;
        *num_values = 0;
index b5672cb2a1acbfc00ac866e8854beef019a4194f..3257ec92150deb8bd2145b781470393930e61d4c 100644 (file)
@@ -709,7 +709,7 @@ static void display_reg_value(REGISTRY_VALUE value)
                break;
        }
        case REG_MULTI_SZ: {
-               int i, num_values;
+               uint32 i, num_values;
                char **values;
 
                if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
index dc3cb42dbe6cb444ab475b90aab62705db6128a7..5a18253aaf71ea70b02aadc1b40d47458c0cbc1f 100644 (file)
@@ -129,7 +129,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
                break;
 
        case REG_MULTI_SZ: {
-               int i, num_values;
+               uint32 i, num_values;
                char **values;
 
                if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
index a04c527502831834712ba15e476e3e7b00ade714..45598c49f5e01b2c4316a520b7ec8f93f414fc5d 100644 (file)
@@ -197,7 +197,7 @@ static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx,
        struct registry_value *value;
        NTSTATUS status;
 
-       if (!(value = TALLOC_P(mem_ctx, struct registry_value))) {
+       if (!(value = TALLOC_ZERO_P(mem_ctx, struct registry_value))) {
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -247,6 +247,18 @@ static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx,
                }
                break;
        }
+       case REG_MULTI_SZ:
+               status = reg_pull_multi_sz(value, (void *)data, length,
+                                          &value->v.multi_sz.num_strings,
+                                          &value->v.multi_sz.strings);
+               if (!(NT_STATUS_IS_OK(status))) {
+                       goto error;
+               }
+               break;
+       case REG_BINARY:
+               value->v.binary.data = talloc_move(value, &data);
+               value->v.binary.length = length;
+               break;
        default:
                status = NT_STATUS_INVALID_PARAMETER;
                goto error;
@@ -466,6 +478,18 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
                case REG_EXPAND_SZ:
                        d_printf("Value      = \"%s\"\n", v->v.sz.str);
                        break;
+               case REG_MULTI_SZ: {
+                       uint32 j;
+                       for (j = 0; j < v->v.multi_sz.num_strings; j++) {
+                               d_printf("Value[%3.3d] = \"%s\"\n", j,
+                                        v->v.multi_sz.strings[j]);
+                       }
+                       break;
+               }
+               case REG_BINARY:
+                       d_printf("Value      = %d bytes\n",
+                                v->v.binary.length);
+                       break;
                default:
                        d_printf("Value      = <unprintable>\n");
                        break;