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

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