Blame SOURCES/evolution-data-server-3.28.5-CVE-2020-14928.patch

faa13a
diff -up evolution-data-server-3.28.5/src/camel/camel-stream-buffer.c.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/camel-stream-buffer.c
faa13a
--- evolution-data-server-3.28.5/src/camel/camel-stream-buffer.c.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/camel-stream-buffer.c	2020-07-23 10:26:57.962555350 +0200
faa13a
@@ -524,3 +524,22 @@ camel_stream_buffer_read_line (CamelStre
faa13a
 
faa13a
 	return g_strdup ((gchar *) sbf->priv->linebuf);
faa13a
 }
faa13a
+
faa13a
+/*
faa13a
+ * camel_stream_buffer_discard_cache:
faa13a
+ * @sbf: a #CamelStreamBuffer
faa13a
+ *
faa13a
+ * Discards any cached data in the @sbf. The next read reads
faa13a
+ * from the stream.
faa13a
+ *
faa13a
+ * Since: 3.28.5-14
faa13a
+ */
faa13a
+void
faa13a
+camel_stream_buffer_discard_cache (CamelStreamBuffer *sbf)
faa13a
+{
faa13a
+	g_return_if_fail (CAMEL_IS_STREAM_BUFFER (sbf));
faa13a
+
faa13a
+	sbf->priv->ptr = sbf->priv->buf;
faa13a
+	sbf->priv->end = sbf->priv->buf;
faa13a
+	sbf->priv->ptr[0] = '\0';
faa13a
+}
faa13a
diff -up evolution-data-server-3.28.5/src/camel/camel-stream-buffer.h.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/camel-stream-buffer.h
faa13a
--- evolution-data-server-3.28.5/src/camel/camel-stream-buffer.h.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/camel-stream-buffer.h	2020-07-23 10:26:57.963555348 +0200
faa13a
@@ -93,6 +93,8 @@ gint		camel_stream_buffer_gets	(CamelStr
faa13a
 gchar *		camel_stream_buffer_read_line	(CamelStreamBuffer *sbf,
faa13a
 						 GCancellable *cancellable,
faa13a
 						 GError **error);
faa13a
+void		camel_stream_buffer_discard_cache
faa13a
+						(CamelStreamBuffer *sbf);
faa13a
 
faa13a
 G_END_DECLS
faa13a
 
faa13a
diff -up evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-store.c.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-store.c
faa13a
--- evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-store.c.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-store.c	2020-07-23 10:26:57.963555348 +0200
faa13a
@@ -208,6 +208,8 @@ connect_to_server (CamelService *service
faa13a
 
faa13a
 	if (tls_stream != NULL) {
faa13a
 		camel_stream_set_base_stream (stream, tls_stream);
faa13a
+		/* Truncate any left cached input from the insecure part of the session */
faa13a
+		camel_pop3_stream_discard_cache (pop3_engine->stream);
faa13a
 		g_object_unref (tls_stream);
faa13a
 	} else {
faa13a
 		g_prefix_error (
faa13a
diff -up evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.c.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.c
faa13a
--- evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.c.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.c	2020-07-23 10:26:57.963555348 +0200
faa13a
@@ -457,3 +457,14 @@ camel_pop3_stream_getd (CamelPOP3Stream
faa13a
 
faa13a
 	return 1;
faa13a
 }
faa13a
+
faa13a
+void
faa13a
+camel_pop3_stream_discard_cache (CamelPOP3Stream *is)
faa13a
+{
faa13a
+	if (is) {
faa13a
+		is->ptr = is->end = is->buf;
faa13a
+		is->lineptr = is->linebuf;
faa13a
+		is->lineend = is->linebuf + CAMEL_POP3_STREAM_LINE_SIZE;
faa13a
+		is->ptr[0] = '\n';
faa13a
+	}
faa13a
+}
faa13a
diff -up evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.h.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.h
faa13a
--- evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.h.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/providers/pop3/camel-pop3-stream.h	2020-07-23 10:26:57.963555348 +0200
faa13a
@@ -87,6 +87,7 @@ gint		camel_pop3_stream_getd		(CamelPOP3
faa13a
 						 guint *len,
faa13a
 						 GCancellable *cancellable,
faa13a
 						 GError **error);
faa13a
+void		camel_pop3_stream_discard_cache	(CamelPOP3Stream *is);
faa13a
 
faa13a
 G_END_DECLS
faa13a
 
faa13a
diff -up evolution-data-server-3.28.5/src/camel/providers/smtp/camel-smtp-transport.c.CVE-2020-14928 evolution-data-server-3.28.5/src/camel/providers/smtp/camel-smtp-transport.c
faa13a
--- evolution-data-server-3.28.5/src/camel/providers/smtp/camel-smtp-transport.c.CVE-2020-14928	2018-07-30 15:17:06.000000000 +0200
faa13a
+++ evolution-data-server-3.28.5/src/camel/providers/smtp/camel-smtp-transport.c	2020-07-23 10:26:57.963555348 +0200
faa13a
@@ -319,6 +319,8 @@ connect_to_server (CamelService *service
faa13a
 
faa13a
 	if (tls_stream != NULL) {
faa13a
 		camel_stream_set_base_stream (stream, tls_stream);
faa13a
+		/* Truncate any left cached input from the insecure part of the session */
faa13a
+		camel_stream_buffer_discard_cache (transport->istream);
faa13a
 		g_object_unref (tls_stream);
faa13a
 	} else {
faa13a
 		g_prefix_error (