Commit 7ffbaceb authored by Guido Gunther's avatar Guido Gunther

Geary.RFC822.Message: Handle 0 size of body and header in from_parts().

parent 5b3f49ab
Pipeline #64711 failed with stages
in 10 minutes and 38 seconds
From: Marek Benc <dusxmt@gmx.com>
Date: Sun, 14 Feb 2021 16:07:47 +0100
Subject: Geary.RFC822.Message: Handle 0 size of body and header in
from_parts().
Fixes #1137
---
src/engine/rfc822/rfc822-message.vala | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index e6cc17a..521058d 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -194,8 +194,15 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
public Message.from_parts(Header header, Text body)
throws Error {
GMime.StreamCat stream_cat = new GMime.StreamCat();
- stream_cat.add_source(new GMime.StreamMem.with_buffer(header.buffer.get_bytes().get_data()));
- stream_cat.add_source(new GMime.StreamMem.with_buffer(body.buffer.get_bytes().get_data()));
+
+ if (header.buffer.size != 0) {
+ stream_cat.add_source(new GMime.StreamMem.with_buffer(header.buffer.get_bytes().get_data()));
+ } else {
+ throw new Error.INVALID("Missing header in RFC 822 message");
+ }
+ if (body.buffer.size != 0) {
+ stream_cat.add_source(new GMime.StreamMem.with_buffer(body.buffer.get_bytes().get_data()));
+ }
GMime.Parser parser = new GMime.Parser.with_stream(stream_cat);
var message = parser.construct_message(Geary.RFC822.get_parser_options());
Geary.RFC822.Message-Handle-0-size-of-body-and-header-in-.patch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment