]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: test-mech - Allocate test input explicitly
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 26 Aug 2020 08:42:02 +0000 (11:42 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 11:47:59 +0000 (11:47 +0000)
This way valgrind will catch if there are read buffer overflows.

src/auth/test-mech.c

index d9429c95d821f3ef56915e2acfbce4bd03d3ec4c..322c1e9c69d9955dd5d237ff5ffe29516dba7028 100644 (file)
@@ -343,7 +343,9 @@ static void test_mechs(void)
                        test_expect_error_string(test_case->expect_error);
 
                request->state = AUTH_REQUEST_STATE_NEW;
-               request->initial_response = test_case->in;
+               unsigned char *input_dup = test_case->len == 0 ? NULL :
+                       i_memdup(test_case->in, test_case->len);
+               request->initial_response = input_dup;
                request->initial_response_len = test_case->len;
                auth_request_initial(request);
 
@@ -381,6 +383,7 @@ static void test_mechs(void)
 
                event_unref(&request->event);
                event_unref(&request->mech_event);
+               i_free(input_dup);
                mech->auth_free(request);
 
                test_end();