sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit b5677a29691bd1bf02c071c83afc5d8c875c65a5
parent 0d768032d39ab8e4b36ed8b06fd4742a1f6acace
Author: Gaudenz Steinlin <gaudenz@soziologie.ch>
Date:   Thu, 17 Feb 2011 15:26:41 +0100

Check for valid signature before signature.to_s

In some circumstances with broken signatures signature.to_s returns nil.
Check for a valid signature before relying on this string. This avoids
an uncaught exception.

Signed-off-by: Hamish Downer 

Diffstat:
M lib/sup/crypto.rb | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -341,7 +341,13 @@ private
     ctx = GPGME::Ctx.new
     begin
       from_key = ctx.get_key(signature.fingerprint)
-      first_sig = signature.to_s.sub(/from [0-9A-F]{16} /, 'from "') + '"'
+      if GPGME::gpgme_err_code(signature.status) == GPGME::GPG_ERR_GENERAL
+        first_sig = "General error on signature verification for #{signature.fingerprint}"
+      elsif signature.to_s
+        first_sig = signature.to_s.sub(/from [0-9A-F]{16} /, 'from "') + '"'
+      else
+        first_sig = "Unknown error or empty signature"
+      end
     rescue EOFError 
       from_key = nil
       first_sig = "No public key available for #{signature.fingerprint}"