]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: Fix corrupted error message when istream read fails
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 20 Jun 2023 12:03:46 +0000 (15:03 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 24 Jul 2023 08:48:17 +0000 (08:48 +0000)
i_stream_get_error() return value may point to memory allocated from
istream. redis_disconnected() calls connection_disconnect(), which frees
this memory. The error is still used, but now it's corrupted.

src/lib-dict/dict-redis.c

index b14376eb2b40e3fbe4b5090b63806de263b41880..06d448e1301a4379668b9ff28a1402c045681a60 100644 (file)
@@ -95,7 +95,10 @@ static void
 redis_disconnected(struct redis_connection *conn, const char *reason)
 {
        const struct dict_commit_result result = {
-               DICT_COMMIT_RET_FAILED, reason
+               DICT_COMMIT_RET_FAILED,
+               /* t_strdup() in case reason points to istream, which gets
+                  freed by connection_disconnect() */
+               t_strdup(reason)
        };
        const struct redis_dict_reply *reply;