[svn] GpgOL - r217 - trunk/src
svn author wk
cvs at cvs.gnupg.org
Thu Feb 7 12:46:49 CET 2008
Author: wk
Date: 2008-02-07 12:46:47 +0100 (Thu, 07 Feb 2008)
New Revision: 217
Modified:
trunk/src/ChangeLog
trunk/src/mapihelp.cpp
trunk/src/message.cpp
Log:
Fixed PGP inline encrypted message decryption.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-02-06 14:11:25 UTC (rev 216)
+++ trunk/src/ChangeLog 2008-02-07 11:46:47 UTC (rev 217)
@@ -1,3 +1,8 @@
+2008-02-07 Werner Koch <wk at g10code.com>
+
+ * message.cpp (message_wipe_body_cruft): Delete only encrypted
+ messages.
+
2008-02-06 Werner Koch <wk at g10code.com>
* mimeparser.c (mime_decrypt): New arg IS_RFC822.
Modified: trunk/src/mapihelp.cpp
===================================================================
--- trunk/src/mapihelp.cpp 2008-02-06 14:11:25 UTC (rev 216)
+++ trunk/src/mapihelp.cpp 2008-02-07 11:46:47 UTC (rev 217)
@@ -1777,7 +1777,7 @@
/* Returns True if MESSAGE has a GpgOL Last Decrypted property and
- that matches the curren sessiobn. */
+ that matches the current session. */
int
mapi_test_last_decrypted (LPMESSAGE message)
{
@@ -1787,10 +1787,10 @@
int yes = 0;
if (get_gpgollastdecrypted_tag (message, &tag) )
- return 0; /* No. */
+ goto leave; /* No. */
hr = HrGetOneProp ((LPMAPIPROP)message, tag, &propval);
if (FAILED (hr))
- return 0; /* No. */
+ goto leave; /* No. */
if (PROP_TYPE (propval->ulPropTag) == PT_BINARY
&& propval->Value.bin.cb == 8
@@ -1798,6 +1798,9 @@
yes = 1;
MAPIFreeBuffer (propval);
+ leave:
+ log_debug ("%s:%s: message decrypted during this session: %s\n",
+ SRCNAME, __func__, yes?"yes":"no");
return yes;
}
Modified: trunk/src/message.cpp
===================================================================
--- trunk/src/message.cpp 2008-02-06 14:11:25 UTC (rev 216)
+++ trunk/src/message.cpp 2008-02-07 11:46:47 UTC (rev 217)
@@ -190,44 +190,63 @@
hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
if (SUCCEEDED (hr))
{
- if (mapi_has_last_decrypted (message))
+ switch (mapi_get_message_type (message))
{
- SPropTagArray proparray;
- int anyokay = 0;
-
- proparray.cValues = 1;
- proparray.aulPropTag[0] = PR_BODY;
- hr = message->DeleteProps (&proparray, NULL);
- if (hr)
- log_debug_w32 (hr, "%s:%s: deleting PR_BODY failed",
- SRCNAME, __func__);
- else
- anyokay++;
-
- proparray.cValues = 1;
- proparray.aulPropTag[0] = PR_BODY_HTML;
- message->DeleteProps (&proparray, NULL);
- if (hr)
- log_debug_w32 (hr, "%s:%s: deleting PR_BODY_HTML failed",
- SRCNAME, __func__);
- else
- anyokay++;
+ case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
+ case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
+ {
+ if (mapi_has_last_decrypted (message))
+ {
+ SPropTagArray proparray;
+ int anyokay = 0;
+
+ proparray.cValues = 1;
+ proparray.aulPropTag[0] = PR_BODY;
+ hr = message->DeleteProps (&proparray, NULL);
+ if (hr)
+ log_debug_w32 (hr, "%s:%s: deleting PR_BODY failed",
+ SRCNAME, __func__);
+ else
+ anyokay++;
+
+ proparray.cValues = 1;
+ proparray.aulPropTag[0] = PR_BODY_HTML;
+ message->DeleteProps (&proparray, NULL);
+ if (hr)
+ log_debug_w32 (hr, "%s:%s: deleting PR_BODY_HTML failed",
+ SRCNAME, __func__);
+ else
+ anyokay++;
- if (anyokay)
- {
- hr = message->SaveChanges (KEEP_OPEN_READWRITE);
- if (hr)
- log_error_w32 (hr, "%s:%s: SaveChanges failed",
- SRCNAME, __func__);
- else
- log_debug ("%s:%s: SaveChanges succeded; body cruft removed",
- SRCNAME, __func__);
- }
- }
- else
- log_debug_w32 (hr, "%s:%s: error getting message",
- SRCNAME, __func__);
-
+ if (anyokay)
+ {
+ hr = message->SaveChanges (KEEP_OPEN_READWRITE);
+ if (hr)
+ log_error_w32 (hr, "%s:%s: SaveChanges failed",
+ SRCNAME, __func__);
+ else
+ log_debug ("%s:%s: SaveChanges succeded; "
+ "body cruft removed",
+ SRCNAME, __func__);
+ }
+ }
+ else
+ log_debug_w32 (hr, "%s:%s: "
+ "error getting message decryption status",
+ SRCNAME, __func__);
+ }
+ break;
+
+ case MSGTYPE_GPGOL_PGP_MESSAGE:
+ /* We can't delete the body of a message if it is an inline
+ PGP encrypted message because the body holds the
+ ciphertext. */
+ break;
+
+ default:
+ break;
+ }
+
ul_release (message, __func__);
ul_release (mdb, __func__);
}
More information about the Gnupg-commits
mailing list