registry: Fix Coverity ID 1034918 Wrong sizeof argument
authorVolker Lendecke <vl@samba.org>
Sat, 9 Nov 2013 17:40:08 +0000 (18:40 +0100)
committerIra Cooper <ira@samba.org>
Mon, 11 Nov 2013 20:04:08 +0000 (21:04 +0100)
sizeof(data_val) is the size of the pointer. This might well be 8 bytes
where the string is only 4 bytes long

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
source4/lib/registry/tests/registry.c

index 0c3c395e65f91688a3054f8557dd0c85bad2328a..b9b7c288e6dc90dffc7599e9a64920283435863f 100644 (file)
@@ -552,14 +552,14 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
                                  "getting missing value");
 
        error = reg_val_set(subkey, "", REG_SZ,
-                           data_blob_talloc(tctx, data_val, sizeof(data_val)));
+                           data_blob_talloc(tctx, data_val, strlen(data_val)));
        torture_assert_werr_ok(tctx, error, "set default value");
 
        error = reg_key_get_value_by_index(tctx, subkey, 0, &name,
                                           &type, &data);
        torture_assert_werr_ok(tctx, error, "getting default value");
        torture_assert_int_equal(tctx, REG_SZ, type, "value type ok");
-       torture_assert_int_equal(tctx, sizeof(data_val), data.length, "value length ok");
+       torture_assert_int_equal(tctx, strlen(data_val), data.length, "value length ok");
        torture_assert_str_equal(tctx, data_val, (char *)data.data, "value ok");
 
        return true;