[PATCH] wintrust: Verify array length before calling memcmp in test (valgrind).

Roy Shea royshea at gmail.com
Wed Jun 18 22:34:50 CDT 2008

Call to memcmp in test_calchash assumes length of hash and expectedhash
are the same.  This need not be true in general, and is not true for the
current stub implementation of CryptCATAdminCalcHashFromFileHandle.
This patch adds an explicit test of array length.  In doing so it
prevents the following Valgrind warning:

Conditional jump or move depends on uninitialised value(s)
    at  winetest_vok (test.h:256)
    by  winetest_ok (test.h:301)
    by  test_calchash (crypt.c:338)
    by  func_crypt (crypt.c:359)
    by  run_test (test.h:449)

Note that the Valgrind warning listed above is a "heisenbug" that is
only occasionally detected by Valgrind.
 dlls/wintrust/tests/crypt.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/dlls/wintrust/tests/crypt.c b/dlls/wintrust/tests/crypt.c
index c28f98c..ee77bbc 100644
--- a/dlls/wintrust/tests/crypt.c
+++ b/dlls/wintrust/tests/crypt.c
@@ -335,6 +335,7 @@ static void test_calchash(void)
     ok(GetLastError() == ERROR_SUCCESS,
        "Expected ERROR_SUCCESS, got %d\n", GetLastError());
+    ok(hashsize == sizeof(expectedhash), "Hash lengths don't match\n");
     ok(!memcmp(hash, expectedhash, sizeof(expectedhash)), "Hashes didn't match\n");

More information about the wine-patches mailing list