[geary: 1/2] Geary.RFC822.Message: Handle 0 size of body and header in from_parts().
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 1/2] Geary.RFC822.Message: Handle 0 size of body and header in from_parts().
- Date: Tue, 23 Feb 2021 21:47:41 +0000 (UTC)
commit 0bffbd2c5ddbeb7b0df5d31dd12f39df5ce5116e
Author: Marek Benc <dusxmt gmx com>
Date: Sun Feb 14 16:07:47 2021 +0100
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 e6cc17a40..521058dea 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());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]