From 8eff3ba970ca459d172046c749e4763f0dc50174 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 6 Apr 2020 16:49:42 +0000 Subject: Improve comparision with test data. First check the client random against the zeroed value, then zero the client random in the client hello, before comparing with the golden value. This makes failures more obvious and the test code more readable. --- src/regress/lib/libssl/client/clienttest.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libssl/client/clienttest.c b/src/regress/lib/libssl/client/clienttest.c index b22b26eca4..5a76e66f8c 100644 --- a/src/regress/lib/libssl/client/clienttest.c +++ b/src/regress/lib/libssl/client/clienttest.c @@ -347,7 +347,6 @@ client_hello_test(int testno, struct client_hello_test *cht) size_t client_hello_len; char *wbuf, rbuf[1]; int ret = 1; - size_t i; long len; fprintf(stderr, "Test %i - %s\n", testno, cht->desc); @@ -402,14 +401,17 @@ client_hello_test(int testno, struct client_hello_test *cht) } /* We expect the client random to differ. */ - i = cht->random_start + SSL3_RANDOM_SIZE; - if (memcmp(client_hello, wbuf, cht->random_start) != 0 || - memcmp(&client_hello[cht->random_start], - &wbuf[cht->random_start], SSL3_RANDOM_SIZE) == 0 || - memcmp(&client_hello[i], &wbuf[i], len - i) != 0) { + if (memcmp(&client_hello[cht->random_start], &wbuf[cht->random_start], + SSL3_RANDOM_SIZE) == 0) { + fprintf(stderr, "FAIL: ClientHello has zeroed random\n"); + goto failure; + } + + memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE); + + if (memcmp(client_hello, wbuf, client_hello_len) != 0) { fprintf(stderr, "FAIL: ClientHello differs:\n"); fprintf(stderr, "received:\n"); - memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE); hexdump(wbuf, len); fprintf(stderr, "test data:\n"); hexdump(client_hello, client_hello_len); -- cgit v1.2.3-55-g6feb