[svn] GpgOL - r224 - in trunk: . doc po src

svn author wk cvs at cvs.gnupg.org
Tue Feb 26 13:17:37 CET 2008


Author: wk
Date: 2008-02-26 13:17:34 +0100 (Tue, 26 Feb 2008)
New Revision: 224

Modified:
   trunk/NEWS
   trunk/configure.ac
   trunk/doc/gpgol.texi
   trunk/po/de.po
   trunk/po/sv.po
   trunk/src/ChangeLog
   trunk/src/common.c
   trunk/src/common.h
   trunk/src/mapihelp.cpp
   trunk/src/message.cpp
   trunk/src/mimeparser.c
Log:
Tweak for some opaque S/MIME messages.
Pop up messages on errors.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/ChangeLog	2008-02-26 12:17:34 UTC (rev 224)
@@ -1,3 +1,18 @@
+2008-02-26  Werner Koch  <wk at g10code.com>
+
+	* common.c (qp_decode): Add arg S_LBRK.
+	* mimeparser.c (plaintext_handler, ciphertext_handler): Handle
+	soft line breaks.
+
+	* mapihelp.cpp (mapi_change_message_class): Handle opaque S/MIME
+	messages without an smime-type parameter.
+
+2008-02-25  Werner Koch  <wk at g10code.com>
+
+	* message.cpp (message_verify): Show message boxes for non-signed
+	messages.
+	(message_decrypt): Likewise.
+
 2008-02-19  Marcus Brinkmann  <marcus at g10code.de>
 
 	* engine-assuan.c (get_uiserver_name): Change default uiserver

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/NEWS	2008-02-26 12:17:34 UTC (rev 224)
@@ -1,9 +1,22 @@
-Noteworthy changes for version 0.10.5 (2008-02-18)
+Noteworthy changes for version 0.10.6
 ==================================================
 
  UNDER HEAVY DEVELOPMENT - DO NOT USE FOR PRODUCTION!
     - Under OL2007 some menu entries are missing.
 
+ * More tweaks to allow processing of opaque encrypted or signed
+   S/MIME.
+
+ * Shows an error message when trying to decrypt/verify messages not
+   signed or encrypted.
+
+ * Soft line breaks in QP encoded messages are now correctly
+   processed.
+
+
+Noteworthy changes for version 0.10.5 (2008-02-18)
+==================================================
+
  * PGP inline encrypted mails are not anymore deleted after the first
    decryption.
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/configure.ac	2008-02-26 12:17:34 UTC (rev 224)
@@ -16,8 +16,8 @@
 # Remember to change the version number immediately *after* a release.
 # Set my_issvn to "yes" for non-released code.  Remember to run an
 # "svn up" and "autogen.sh" right before creating a distribution.
-m4_define([my_version], [0.10.5])
-m4_define([my_issvn], [no])
+m4_define([my_version], [0.10.6])
+m4_define([my_issvn], [yes])
 
 m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))

Modified: trunk/doc/gpgol.texi
===================================================================
--- trunk/doc/gpgol.texi	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/doc/gpgol.texi	2008-02-26 12:17:34 UTC (rev 224)
@@ -518,7 +518,7 @@
 
 @deffn Command START_KEYMANAGER
 The server shall pop up the main window of the key manager (aka
-certificate manager).  The client expects that the key manger is brought
+certificate manager).  The client expects that the key manager is brought
 into the foregound and that this command immediatley returns (does not
 wait until the key manager has been fully brought up).
 @end deffn

Modified: trunk/po/de.po  [not shown]
Modified: trunk/po/sv.po  [not shown]
Modified: trunk/src/common.c
===================================================================
--- trunk/src/common.c	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/common.c	2008-02-26 12:17:34 UTC (rev 224)
@@ -599,12 +599,19 @@
 
 
 /* Do in-place decoding of quoted-printable data of LENGTH in BUFFER.
-   Returns the new length of the buffer. */
+   Returns the new length of the buffer and stores true at R_SLBRK if
+   the line ended with a soft line break; false is stored if not.
+   This fucntion asssumes that a complete line is passed in
+   buffer.  */
 size_t
-qp_decode (char *buffer, size_t length)
+qp_decode (char *buffer, size_t length, int *r_slbrk)
 {
   char *d, *s;
 
+  if (r_slbrk)
+    *r_slbrk = 0;
+
+  /* Fixme:  We should remove trailing white space first.  */
   for (s=d=buffer; length; length--)
     if (*s == '=')
       {
@@ -620,13 +627,24 @@
             /* Soft line break.  */
             s += 3;
             length -= 2;
+            if (r_slbrk && length == 1)
+              *r_slbrk = 1;
           }
         else if (length > 1 && s[1] == '\n')
           {
             /* Soft line break with only a Unix line terminator. */
             s += 2;
             length -= 1;
+            if (r_slbrk && length == 1)
+              *r_slbrk = 1;
           }
+        else if (length == 1)
+          {
+            /* Soft line break at the end of the line. */
+            s += 1;
+            if (r_slbrk)
+              *r_slbrk = 1;
+          }
         else
           *d++ = *s++;
       }

Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/common.h	2008-02-26 12:17:34 UTC (rev 224)
@@ -181,7 +181,7 @@
 
 const char *default_homedir (void);
 
-size_t qp_decode (char *buffer, size_t length);
+size_t qp_decode (char *buffer, size_t length, int *r_slbrk);
 void b64_init (b64_state_t *state);
 size_t b64_decode (b64_state_t *state, char *buffer, size_t length);
 

Modified: trunk/src/mapihelp.cpp
===================================================================
--- trunk/src/mapihelp.cpp	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/mapihelp.cpp	2008-02-26 12:17:34 UTC (rev 224)
@@ -500,14 +500,21 @@
 }
 
 
-/* Check whether the message is really a CMS encrypted message.  This
-   function is required due to a bug in CryptoEx which sometimes
-   assignes the *.CexEnc message class to signed messages and only
-   updates the message class after accessing them.  Thus in old stores
-   there may be a lot of *.CexEnc message which are actually just
-   signed.  We check here whether such a message is really encrypted
-   by looking at the object identifier inside the CMS data.  Returns
-   true if the message is really encrypted.  */
+/* Check whether the message is really a CMS encrypted message.  
+   We check here whether the message is really encrypted by looking at
+   the object identifier inside the CMS data.  Returns true if the
+   message is really encrypted.
+
+   This function is required for two reasons: 
+
+   1. Due to a bug in CryptoEx which sometimes assignes the *.CexEnc
+      message class to signed messages and only updates the message
+      class after accessing them.  Thus in old stores there may be a
+      lot of *.CexEnc message which are actually just signed.
+ 
+   2. Is the smime-typeparameter is missing we need another way to
+      decide whether to decrypt or to verify.
+ */
 static int
 is_really_cms_encrypted (LPMESSAGE message)
 {    
@@ -746,6 +753,18 @@
                     }
                   xfree (smtype);
                 }
+              else
+                {
+                  /* No smime type.  The filename parameter is often
+                     not reliable, thus we better look into the
+                     message to see whetehr it is encrypted and assume
+                     an opaque signed one if not.  */
+                  if (is_really_cms_encrypted (message))
+                    newvalue = xstrdup ("IPM.Note.GpgOL.OpaqueEncrypted");
+                  else
+                    newvalue = xstrdup ("IPM.Note.GpgOL.OpaqueSigned");
+                }
+              
               xfree (ct);
             }
           if (!newvalue)

Modified: trunk/src/message.cpp
===================================================================
--- trunk/src/message.cpp	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/message.cpp	2008-02-26 12:17:34 UTC (rev 224)
@@ -30,6 +30,7 @@
 #include "mimeparser.h"
 #include "mimemaker.h"
 #include "display.h"
+#include "ol-ext-callback.h"
 #include "message.h"
 
 #define TRACEPOINT() do { log_debug ("%s:%s:%d: tracepoint\n", \
@@ -157,14 +158,21 @@
       err = mapi_get_gpgol_body_attachment (message, &body, NULL, 
                                             &ishtml, &wasprotected);
       if (!err && body)
-        update_display (hwnd, /*wasprotected? NULL:*/ eecb, ishtml, body);
+        {
+          put_outlook_property (eecb, "GpgOLStatus", 
+                                mapi_get_sig_status (message));
+
+          update_display (hwnd, /*wasprotected? NULL:*/ eecb, ishtml, body);
+        }
       else
-        update_display (hwnd, NULL, 0, 
-                        _("[Crypto operation failed - "
-                          "can't show the body of the message]"));
+        {
+          put_outlook_property (eecb, "GpgOLStatus", "?");
+          update_display (hwnd, NULL, 0, 
+                          _("[Crypto operation failed - "
+                            "can't show the body of the message]"));
+        }
       xfree (body);
   
-      /*  put_outlook_property (eecb, "EncryptedStatus", "MyStatus"); */
     }
   else
     log_debug_w32 (hr, "%s:%s: error getting message", SRCNAME, __func__);
@@ -312,7 +320,13 @@
 }
 
 
+static void
+show_message (HWND hwnd, const char *text)
+{
+  MessageBox (hwnd, text, _("GpgOL"), MB_ICONINFORMATION|MB_OK);
+}
 
+
 
 /* Convert the clear signed message from INPUT into a PGP/MIME signed
    message and return it in a new allocated buffer.  OUTPUTLEN
@@ -520,12 +534,26 @@
     case MSGTYPE_GPGOL_PGP_MESSAGE:
       log_debug ("%s:%s: message of type %d not expected",
                  SRCNAME, __func__, msgtype);
+      if (force)
+        show_message (hwnd, _("Signature verification of an encrypted message "
+                              "is not possible."));
       return -1; /* Should not be called for such a message.  */
+    case MSGTYPE_GPGOL:
+    case MSGTYPE_SMIME:
     case MSGTYPE_UNKNOWN:
-    case MSGTYPE_SMIME:
-    case MSGTYPE_GPGOL:
-      log_debug ("%s:%s: message of type %d ignored",
+      log_debug ("%s:%s: message of type %d ignored", 
                  SRCNAME, __func__, msgtype);
+      if (!force)
+        ;
+      else if (msgtype == MSGTYPE_GPGOL)
+        show_message (hwnd, _("Signature verification of this "
+                              "message class is not possible."));
+      else if (msgtype == MSGTYPE_SMIME)
+        show_message (hwnd, _("Signature verification of this "
+                              "S/MIME message is not possible.  Please check "
+                              "that S/MIME processing has been enabled."));
+      else
+        show_message (hwnd, _("This message has no signature."));
       return 0; /* Nothing to do.  */
     }
   
@@ -824,6 +852,8 @@
     case MSGTYPE_GPGOL_OPAQUE_SIGNED:
     case MSGTYPE_GPGOL_MULTIPART_SIGNED:
     case MSGTYPE_GPGOL_CLEAR_SIGNED:
+      if (force)
+        show_message (hwnd, _("This message is not encrypted.")); 
       return -1; /* Should not have been called for this.  */
     case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
       break;
@@ -1040,8 +1070,17 @@
     {
       char buf[200];
       
-      snprintf (buf, sizeof buf, "Decryption failed (%s)", gpg_strerror (err));
-      MessageBox (NULL, buf, "GpgOL", MB_ICONINFORMATION|MB_OK);
+      switch (gpg_err_code (err))
+        {
+        case GPG_ERR_NO_DATA:
+          /* The UI server already displayed a message.  */
+          break;
+        default:
+          snprintf (buf, sizeof buf,
+                    _("Decryption failed\n(%s)"), gpg_strerror (err));
+          MessageBox (NULL, buf, "GpgOL", MB_ICONINFORMATION|MB_OK);
+          break;
+        }
     }
   else
     {

Modified: trunk/src/mimeparser.c
===================================================================
--- trunk/src/mimeparser.c	2008-02-19 16:03:56 UTC (rev 223)
+++ trunk/src/mimeparser.c	2008-02-26 12:17:34 UTC (rev 224)
@@ -1040,9 +1040,10 @@
               else if (ctx->outstream)
                 {
                   HRESULT hr = 0;
+                  int slbrk = 0;
 
                   if (ctx->is_qp_encoded)
-                    len = qp_decode (ctx->linebuf, pos);
+                    len = qp_decode (ctx->linebuf, pos, &slbrk);
                   else if (ctx->is_base64_encoded)
                     len = b64_decode (&ctx->base64, ctx->linebuf, pos);
                   else
@@ -1055,10 +1056,10 @@
                       hr = IStream_Write (ctx->outstream, ctx->linebuf,
                                           len, NULL);
                     }
-                  if (!hr && !ctx->is_base64_encoded)
+                  if (!hr && !ctx->is_base64_encoded && !slbrk)
                     {
                       char tmp[3] = "\r\n";
-
+                      
                       if (ctx->symenc)
                         symenc_cfb_encrypt (ctx->symenc, tmp, tmp, 2);
                       hr = IStream_Write (ctx->outstream, tmp, 2, NULL);
@@ -1082,15 +1083,17 @@
                 ctx->collect_signature = 2;
               else if (ctx->sig_data)
                 {
+                  int slbrk = 0;
+
                   if (ctx->is_qp_encoded)
-                    len = qp_decode (ctx->linebuf, pos);
+                    len = qp_decode (ctx->linebuf, pos, &slbrk);
                   else if (ctx->is_base64_encoded)
                     len = b64_decode (&ctx->base64, ctx->linebuf, pos);
                   else
                     len = pos;
                   if (len)
                     gpgme_data_write (ctx->sig_data, ctx->linebuf, len);
-                  if (!ctx->is_base64_encoded)
+                  if (!ctx->is_base64_encoded && !slbrk)
                     gpgme_data_write (ctx->sig_data, "\r\n", 2);
                 }
             }
@@ -1503,8 +1506,10 @@
               /* We are inside the data.  That should be the actual
                  ciphertext in the given encoding.  Pass it on to the
                  crypto engine. */
+              int slbrk = 0;
+
               if (ctx->is_qp_encoded)
-                len = qp_decode (ctx->linebuf, pos);
+                len = qp_decode (ctx->linebuf, pos, &slbrk);
               else if (ctx->is_base64_encoded)
                 len = b64_decode (&ctx->base64, ctx->linebuf, pos);
               else
@@ -1513,7 +1518,7 @@
                 err = engine_filter (ctx->outfilter, ctx->linebuf, len);
               else
                 err = 0;
-              if (!err && !ctx->is_base64_encoded)
+              if (!err && !ctx->is_base64_encoded && !slbrk)
                 {
                   char tmp[3] = "\r\n";
                   err = engine_filter (ctx->outfilter, tmp, 2);




More information about the Gnupg-commits mailing list