s3-registry: fix REG_MULTI_SZ handling in registry_push_value.
authorGünther Deschner <gd@samba.org>
Wed, 25 Nov 2009 20:34:55 +0000 (21:34 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 25 Nov 2009 20:39:49 +0000 (21:39 +0100)
Catched by smbconftort test on the buildfarm.

Guenther

source3/lib/util_reg_api.c

index 309fa6276227e12d6eb6641c2d24f119d27e77a5..7150444cf67e7150b69c6850711f75273d14034d 100644 (file)
@@ -161,12 +161,29 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx,
                }
                break;
        }
                }
                break;
        }
-       case REG_MULTI_SZ:
-               if (!push_reg_multi_sz(mem_ctx, presult, (const char **)value->v.multi_sz.strings))
-               {
+       case REG_MULTI_SZ: {
+               /* handle the case where we don't get a NULL terminated array */
+               const char **array;
+               int i;
+
+               array = talloc_array(mem_ctx, const char *,
+                                    value->v.multi_sz.num_strings + 1);
+               if (!array) {
+                       return WERR_NOMEM;
+               }
+
+               for (i=0; i < value->v.multi_sz.num_strings; i++) {
+                       array[i] = value->v.multi_sz.strings[i];
+               }
+               array[i] = NULL;
+
+               if (!push_reg_multi_sz(mem_ctx, presult, array)) {
+                       talloc_free(array);
                        return WERR_NOMEM;
                }
                        return WERR_NOMEM;
                }
+               talloc_free(array);
                break;
                break;
+       }
        case REG_BINARY:
                *presult = data_blob_talloc(mem_ctx,
                                            value->v.binary.data,
        case REG_BINARY:
                *presult = data_blob_talloc(mem_ctx,
                                            value->v.binary.data,