]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Remove deprecated src_pos_r parameter from base64_decode()
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Tue, 15 Feb 2022 15:22:06 +0000 (16:22 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 24 Feb 2022 11:21:20 +0000 (11:21 +0000)
The src_pos_r parameter in base64_decode() has been deprecated in commit
afa3db0a6f15e1b1038cb47f0632baa8f23d0f67 and is now removed - both from
the function as well as all it's calls.

20 files changed:
src/auth/auth-request-handler.c
src/auth/mech-scram.c
src/auth/password-scheme-scram.c
src/auth/password-scheme.c
src/doveadm/client-connection-tcp.c
src/doveadm/dsync/dsync-mailbox-state.c
src/imap-hibernate/imap-hibernate-client.c
src/imap-login/imap-proxy.c
src/imap/imap-master-client.c
src/lib-imap-client/imapc-connection.c
src/lib-mail/message-header-decode.c
src/lib-mail/test-message-header-encode.c
src/lib-smtp/smtp-client-connection.c
src/lib/base64.h
src/lib/test-base64.c
src/master/test-auth-client.c
src/pop3-login/client.c
src/pop3-login/pop3-proxy.c
src/submission-login/client.c
src/submission-login/submission-proxy.c

index d4bf53c27657a929b7813ee845ef7ac33c41e115..f9cbd34e81ee31547918c85321c1993c8d76f028 100644 (file)
@@ -667,7 +667,7 @@ bool auth_request_handler_auth_begin(struct auth_request_handler *handler,
 
                /* Initial response encoded in Bas64 */
                buf = t_buffer_create(MAX_BASE64_DECODED_SIZE(len));
-               if (base64_decode(initial_resp, len, NULL, buf) < 0) {
+               if (base64_decode(initial_resp, len, buf) < 0) {
                        auth_request_handler_auth_fail_code(handler, request,
                                AUTH_CLIENT_FAIL_CODE_INVALID_BASE64,
                                "Invalid base64 data in initial response");
@@ -725,7 +725,7 @@ bool auth_request_handler_auth_continue(struct auth_request_handler *handler,
 
        data_len = strlen(data);
        buf = t_buffer_create(MAX_BASE64_DECODED_SIZE(data_len));
-       if (base64_decode(data, data_len, NULL, buf) < 0) {
+       if (base64_decode(data, data_len, buf) < 0) {
                auth_request_handler_auth_fail_code(handler, request,
                        AUTH_CLIENT_FAIL_CODE_INVALID_BASE64,
                        "Invalid base64 data in continued response");
index a90d0d1f9b9119f64a83d5de0804d6f59014484e..fff9f1f605c4becbd58f90cbc02f745ee4a760c8 100644 (file)
@@ -431,7 +431,7 @@ parse_scram_client_final(struct scram_auth_request *request,
 
                request->proof = buffer_create_dynamic(request->pool,
                                        MAX_BASE64_DECODED_SIZE(len));
-               if (base64_decode(&fields[field_count-1][2], len, NULL,
+               if (base64_decode(&fields[field_count-1][2], len,
                                  request->proof) < 0) {
                        *error_r = "Invalid base64 encoding";
                        return FALSE;
index a395074a680477b3f935dc75f342b7e8f4ffbad3..5f91f13a0f8a749fafd30ebce6ba70f90dcbbddd 100644 (file)
@@ -79,7 +79,7 @@ int scram_scheme_parse(const struct hash_method *hmethod, const char *name,
        *salt_r = fields[1];
 
        buf = t_buffer_create(hmethod->digest_size);
-       if (base64_decode(fields[2], strlen(fields[2]), NULL, buf) < 0 ||
+       if (base64_decode(fields[2], strlen(fields[2]), buf) < 0 ||
            buf->used != hmethod->digest_size) {
                *error_r = t_strdup_printf(
                        "Invalid %s StoredKey in passdb", name);
@@ -88,7 +88,7 @@ int scram_scheme_parse(const struct hash_method *hmethod, const char *name,
        memcpy(stored_key_r, buf->data, hmethod->digest_size);
 
        buffer_set_used_size(buf, 0);
-       if (base64_decode(fields[3], strlen(fields[3]), NULL, buf) < 0 ||
+       if (base64_decode(fields[3], strlen(fields[3]), buf) < 0 ||
            buf->used != hmethod->digest_size) {
                *error_r = t_strdup_printf(
                        "Invalid %s ServerKey in passdb", name);
index c572cd3779b5285c8f1b3520d02649cc7dedaf9c..6b903fe44a8d2608cb1cfac0bf346e5f07e238b9 100644 (file)
@@ -179,7 +179,7 @@ int password_decode(const char *password, const char *scheme,
                /* fall through */
        case PW_ENCODING_BASE64:
                buf = t_buffer_create(MAX_BASE64_DECODED_SIZE(len));
-               if (base64_decode(password, len, NULL, buf) < 0) {
+               if (base64_decode(password, len, buf) < 0) {
                        *error_r = "Input isn't valid base64 encoded data";
                        return -1;
                }
index 97c9402455e58200211cc6226e4d9c7bf5926975..23f24dc320486489bf17b5913fa49702422dd5d8 100644 (file)
@@ -369,7 +369,7 @@ client_connection_tcp_authenticate(struct client_connection_tcp *conn)
        }
 
        plain = t_buffer_create(128);
-       if (base64_decode(line + 6, strlen(line + 6), NULL, plain) < 0) {
+       if (base64_decode(line + 6, strlen(line + 6), plain) < 0) {
                i_error("doveadm client sent invalid base64 auth PLAIN data");
                return -1;
        }
index cca24d4bc5eb2a760aca478eace82b98d9122dd4..15240650c59d4e7dcc18670da3368184542bdc9e 100644 (file)
@@ -84,7 +84,7 @@ int dsync_mailbox_states_import(HASH_TABLE_TYPE(dsync_mailbox_state) states,
        unsigned int i, count;
 
        buf = t_buffer_create(strlen(input));
-       if (base64_decode(input, strlen(input), NULL, buf) < 0) {
+       if (base64_decode(input, strlen(input), buf) < 0) {
                *error_r = "Invalid base64 data";
                return -1;
        }
index 4065adc5925819e1d68972db0671eced52ef7d13..8a957476133bcc0bb1be08813c9b68441a3dc3e2 100644 (file)
@@ -153,7 +153,7 @@ imap_hibernate_client_parse_input(const char *const *args, pool_t pool,
                        buffer_t *state_buf;
 
                        state_buf = buffer_create_dynamic(pool, 1024);
-                       if (base64_decode(value, strlen(value), NULL,
+                       if (base64_decode(value, strlen(value),
                                          state_buf) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid state base64 value: %s", value);
index 2c62b5e9c597668b7186a3f7cd9fee6962becf1e..75f874e9b30ffaf14746a51e23afd6fe7a8f0539 100644 (file)
@@ -328,7 +328,7 @@ int imap_proxy_parse_line(struct client *client, const char *line)
 
                str = t_str_new(128);
                if (line[1] != ' ' ||
-                   base64_decode(line+2, strlen(line+2), NULL, str) < 0) {
+                   base64_decode(line+2, strlen(line+2), str) < 0) {
                        const char *reason = t_strdup_printf(
                                "Invalid base64 data in AUTHENTICATE response");
                        login_proxy_failed(client->login_proxy,
index b03e9d9a761480be19f3aba9a49c9ffcab0fc6f1..256059c5fb0f630ddf45cc829db07c9f623b1da7 100644 (file)
@@ -147,21 +147,21 @@ imap_master_client_parse_input(const char *const *args, pool_t pool,
                        input_r->userdb_fields =
                                t_strsplit_tabescaped(value);
                } else if (strcmp(key, "client_input") == 0) {
-                       if (base64_decode(value, strlen(value), NULL,
+                       if (base64_decode(value, strlen(value),
                                          master_input_r->client_input) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid client_input base64 value: %s", value);
                                return -1;
                        }
                } else if (strcmp(key, "client_output") == 0) {
-                       if (base64_decode(value, strlen(value), NULL,
+                       if (base64_decode(value, strlen(value),
                                          master_input_r->client_output) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid client_output base64 value: %s", value);
                                return -1;
                        }
                } else if (strcmp(key, "state") == 0) {
-                       if (base64_decode(value, strlen(value), NULL,
+                       if (base64_decode(value, strlen(value),
                                          master_input_r->state) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid state base64 value: %s", value);
index 5730f947d410edc91bd35199225fcb19eb086c1a..7725848a8d1af1d7aaef09819833285a4691cbf3 100644 (file)
@@ -923,7 +923,7 @@ imapc_connection_authenticate_cb(const struct imapc_command_reply *reply,
 
        input_len = strlen(reply->text_full);
        buf = t_buffer_create(MAX_BASE64_DECODED_SIZE(input_len));
-       if (base64_decode(reply->text_full, input_len, NULL, buf) < 0) {
+       if (base64_decode(reply->text_full, input_len, buf) < 0) {
                imapc_auth_failed(conn, reply,
                                  t_strdup_printf("Server sent non-base64 input for AUTHENTICATE: %s",
                                                  reply->text_full));
index 18f6ca258595bd014cbdaffcca19358ca2d723ba..8057c41b9b01f005c2f7b1806413d50a6e78f15d 100644 (file)
@@ -49,7 +49,7 @@ message_header_decode_encoded(const unsigned char *data, size_t size,
        case 'B':
                if (base64_decode(data + start_pos[1] + 1,
                                  start_pos[2] - start_pos[1] - 1,
-                                 NULL, decodebuf) < 0) {
+                                 decodebuf) < 0) {
                        /* contains invalid data. show what we got so far. */
                }
                break;
index b1c564510b2b36087d063bdce455560041b870b6..7f790c263a210e2f1c52ac9c9e8de1db38f83e0c 100644 (file)
@@ -98,7 +98,7 @@ static bool verify_b(const char *str, unsigned int i, bool starts_with_a)
                                return FALSE;
                }
                buffer_set_used_size(&buf, 0);
-               if (base64_decode(str+start, i-start, NULL, &buf) < 0)
+               if (base64_decode(str+start, i-start, &buf) < 0)
                        return FALSE;
                i++;
 
index 3df55182ee96ca019f8a9f0306f68f84849a7ace..899f8316183f1b17bcc304201b9e354c8c347042 100644 (file)
@@ -774,8 +774,7 @@ smtp_client_connection_auth_cb(const struct smtp_reply *reply,
                input_len = strlen(reply->text_lines[0]);
                buf = buffer_create_dynamic(pool_datastack_create(),
                        MAX_BASE64_DECODED_SIZE(input_len));
-               if (base64_decode(reply->text_lines[0], input_len,
-                                 NULL, buf) < 0) {
+               if (base64_decode(reply->text_lines[0], input_len, buf) < 0) {
                        error = t_strdup_printf(
                                "Authentication failed: "
                                "Server sent non-base64 input for AUTH: %s",
index ec6ac17ae189b8bdcc41a15c7e9eaeefca97b643..01537bfcbe1047089151af9ae456ab59647485a6 100644 (file)
@@ -305,16 +305,10 @@ t_base64_encode_str(enum base64_encode_flags flags, size_t max_line_len,
 
 /* Translates base64 data into binary and appends it to dest buffer. See
    base64_scheme_decode().
-
-   The src_pos_r parameter is deprecated and MUST be NULL.
  */
 static inline int
-base64_decode(const void *src, size_t src_size, size_t *src_pos_r ATTR_UNUSED,
-             buffer_t *dest) ATTR_NULL(3)
+base64_decode(const void *src, size_t src_size, buffer_t *dest)
 {
-       // NOTE: src_pos_r is deprecated here; to be removed in v2.4 */
-       i_assert(src_pos_r == NULL);
-
        return base64_scheme_decode(&base64_scheme, 0, src, src_size, dest);
 }
 
index d024890ed42479059f8eba567c9bb8e14d56c09f..85e85e6ffb343f225dccac9a5720a73e90845e8f 100644 (file)
@@ -85,7 +85,7 @@ static void test_base64_decode(void)
                                        max_decoded_size);
                str = &buf;
                ret = base64_decode(tests[i].input, strlen(tests[i].input),
-                                   NULL, str);
+                                   str);
 
                test_assert_idx(tests[i].ret == ret, i);
                test_assert_idx(strlen(tests[i].output) == str_len(str) &&
@@ -119,7 +119,7 @@ static void test_base64_random(void)
                str_truncate(dest, 0);
                base64_encode(buf, max, str);
                test_assert_idx(base64_decode(str_data(str), str_len(str),
-                                             NULL, dest) >= 0, i);
+                                             dest) >= 0, i);
                test_assert_idx(str_len(dest) == max &&
                                memcmp(buf, str_data(dest), max) == 0, i);
        }
index d161a5b45cdcf1da44a31a81e7c29114f344abbe..239be34c8d40fb4347503db611edf21e677476bd 100644 (file)
@@ -462,7 +462,7 @@ test_auth_handshake_auth(struct server_connection *conn, unsigned int id,
        }
        data = t_buffer_create(256);
        if (resp != NULL) {
-               if (base64_decode(resp, strlen(resp), NULL, data) < 0) {
+               if (base64_decode(resp, strlen(resp), data) < 0) {
                        i_error("Bad AUTH request: Bad base64");
                        return FALSE;
                }
@@ -496,7 +496,7 @@ test_auth_handshake_cont(struct server_connection *conn, unsigned int id,
        resp = args[0];
        data = t_buffer_create(256);
        if (resp != NULL) {
-               if (base64_decode(resp, strlen(resp), NULL, data) < 0) {
+               if (base64_decode(resp, strlen(resp), data) < 0) {
                        i_error("Bad CONT request: Bad base64");
                        return FALSE;
                }
index 1e7b334f890bac83e9d2766d2e7361c4f7972098..ad5c046488072c9bd3fc4ca3010d6efaa53b8bcd 100644 (file)
@@ -73,7 +73,7 @@ static bool cmd_xclient(struct pop3_client *client, const char *args)
                        client->common.forward_fields =
                                str_new(client->common.preproxy_pool,
                                        MAX_BASE64_DECODED_SIZE(value_len));
-                       if (base64_decode((*tmp)+8, value_len, NULL,
+                       if (base64_decode((*tmp)+8, value_len,
                                          client->common.forward_fields) < 0)
                                args_ok = FALSE;
                }
index bcc7a581f8cbed29230b193a4e2e744bb5bcdc66..9600fa3a94a0e475d84312121a524867c2afd2a4 100644 (file)
@@ -110,7 +110,7 @@ pop3_proxy_continue_sasl_auth(struct client *client, struct ostream *output,
        int ret;
 
        str = t_str_new(128);
-       if (base64_decode(line, strlen(line), NULL, str) < 0) {
+       if (base64_decode(line, strlen(line), str) < 0) {
                const char *reason = t_strdup_printf(
                        "Invalid base64 data in AUTH response");
                login_proxy_failed(client->login_proxy,
index 9922c9d438dc014ed3b3b6935cb4d635b73ea6a2..75643e7429ee805e8b50d23249430dbc97f0534a 100644 (file)
@@ -200,7 +200,7 @@ client_connection_cmd_xclient(void *context,
                                client->common.forward_fields = str_new(
                                        client->common.preproxy_pool,
                                        MAX_BASE64_DECODED_SIZE(value_len));
-                               if (base64_decode(value, value_len, NULL,
+                               if (base64_decode(value, value_len,
                                          client->common.forward_fields) < 0) {
                                        smtp_server_reply(cmd, 501, "5.5.4",
                                                "Invalid FORWARD parameter");
index 08cea1be21617cd7f7343fd110340e56a8b9070c..2d616d6516218d1b05a36db55cb4e0e4fe7974b5 100644 (file)
@@ -371,7 +371,7 @@ submission_proxy_continue_sasl_auth(struct client *client,
        }
 
        str = t_str_new(128);
-       if (base64_decode(line, strlen(line), NULL, str) < 0) {
+       if (base64_decode(line, strlen(line), str) < 0) {
                login_proxy_failed(client->login_proxy,
                        login_proxy_get_event(client->login_proxy),
                        LOGIN_PROXY_FAILURE_TYPE_PROTOCOL,