]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Set stream_errno on istream-decrypt read failures.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 6 Jul 2016 10:11:50 +0000 (13:11 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Jul 2016 14:32:59 +0000 (17:32 +0300)
Fixes assert-crashes that would happen otherwise.

src/lib-dcrypt/istream-decrypt.c

index ae39d0d5ab01b98e59993f2990fa3297562e5def..d04b53ffb6500baaea2193f3e62ed215b719d64a 100644 (file)
@@ -734,6 +734,7 @@ i_stream_decrypt_read(struct istream_private *stream)
                                    data, decrypt_size, &error)) {
                                        io_stream_set_error(&stream->iostream,
                                                "MAC error: %s", error);
+                                       stream->istream.stream_errno = EINVAL;
                                        return -1;
                                }
                        }
@@ -747,10 +748,13 @@ i_stream_decrypt_read(struct istream_private *stream)
                                if (!dcrypt_ctx_hmac_final(dstream->ctx_mac, &db, &error)) {
                                        io_stream_set_error(&stream->iostream,
                                                "Cannot verify MAC: %s", error);
+                                       stream->istream.stream_errno = EINVAL;
+                                       return -1;
                                }
                                if (memcmp(dgst, data + decrypt_size, dcrypt_ctx_hmac_get_digest_length(dstream->ctx_mac)) != 0) {
                                        io_stream_set_error(&stream->iostream,
                                                "Cannot verify MAC: mismatch");
+                                       stream->istream.stream_errno = EINVAL;
                                        return -1;
                                }
                        } else if ((dstream->flags & IO_STREAM_ENC_INTEGRITY_AEAD) == IO_STREAM_ENC_INTEGRITY_AEAD) {