Subject: [sup-devel] [PATCH] Fixed inline gpg crash when the end marker is missing

From: Michael Hamann <[email-masked]>
Date: Sat, 4 Sep 2010 23:51:46 +0200

lines.between() does not check if the end marker actually exists, but
later it is assumed the marker exists. This change introduces a check
for the end marker and doesn't decrypt messages in which the end marker
is missing. This is a fix for
http://rubyforge.org/pipermail/sup-talk/2010-August/004209.html
---
 lib/sup/message.rb |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 9f488af..69669bd 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -559,7 +559,8 @@ private
     end
 
     gpg = lines.between(GPG_START, GPG_END)
-    if !gpg.empty?
+    # between does not check if GPG_END actually exists
+    if !gpg.empty? && !lines.index(GPG_END).nil?
       msg = RMail::Message.new
       msg.body = gpg.join("\n")
 
-- 
1.7.2.2

_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Sascha Silbe <[email-masked]>
Date: Tue, 05 Oct 2010 13:42:58 +0200

> http://rubyforge.org/pipermail/sup-talk/2010-August/004209.html

Just encountered this one with some message in the "Error when verifying
tags signed using 1.7.3.1" thread [1] on the git mailing list.
The patch works fine for me, thanks!

FWIW, I think your approach of not trying to decrypt mails that contain
no end marker is the right thing to do: If the end marker is missing,
the message most likely has been garbled in other ways as well (or
simply cut off in the middle), causing decryption to fail anyway.

Sascha

[1] http://marc.info/?t=128623049600001&r=1&w=2
--
http://sascha.silbe.org/
http://www.infra-silbe.de/
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Ben Walton <[email-masked]>
Date: Tue, 05 Oct 2010 09:09:41 -0400

Excerpts from Sascha Silbe's message of Tue Oct 05 07:42:58 -0400 2010:

> Just encountered this one with some message in the "Error when
> verifying tags signed using 1.7.3.1" thread [1] on the git mailing
> list.  The patch works fine for me, thanks!

Yes, me too.  Patch applied and my sup is back in business.

> FWIW, I think your approach of not trying to decrypt mails that
> contain no end marker is the right thing to do: If the end marker is
> missing, the message most likely has been garbled in other ways as
> well (or simply cut off in the middle), causing decryption to fail
> anyway.

I agree with this rationale.  Feeding the entire message to gpg if no
end marker is seen isn't the way to go, I don't think.

Rich, can this hit master?

Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

---

From: "Edward Z. Yang" <[email-masked]>
Date: Sat, 11 Sep 2010 12:42:50 -0400

> http://rubyforge.org/pipermail/sup-talk/2010-August/004209.html

Hello Michael,

It may be desirable to assume an implicit end marker at the end
of a message if it does not exist, to deal with certain malformed
PGP messages that were also complained about on this list.

Cheers,
Edward

---

From: Rich Lane <[email-masked]>
Date: Fri, 08 Oct 2010 00:23:53 -0400

Applied to master.