]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: test-mech - Fix empty initial reponse tests
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 2 Nov 2023 13:33:50 +0000 (14:33 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Nov 2023 10:49:10 +0000 (10:49 +0000)
Empty initial responses were interpreted as the absense of an initial response,
thereby triggering an empty server challenge and a subsequent erroneous failure.
This was not how these tests were intended.

src/auth/test-mech.c

index d6150a1cd1ec032f9b40d058ff8112d26a14d8d3..d574e78ae858bbbf721a717aa3aa39ee8db93d56 100644 (file)
@@ -341,8 +341,8 @@ static void test_mechs(void)
                        test_expect_error_string(test_case->expect_error);
 
                request->state = AUTH_REQUEST_STATE_NEW;
-               unsigned char *input_dup = test_case->len == 0 ? NULL :
-                       i_memdup(test_case->in, test_case->len);
+               unsigned char *input_dup = i_malloc(I_MAX(test_case->len, 1));
+               memcpy(input_dup, test_case->in, test_case->len);
                request->initial_response = input_dup;
                request->initial_response_len = test_case->len;
                auth_request_initial(request);