[git] GpgOL - branch, master, updated. gpgol-1.2.0-7-g35e6859

by Werner Koch cvs at cvs.gnupg.org
Thu Apr 9 19:18:52 CEST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  35e68591863b7da1698ddc24d8f035fc4c382b9a (commit)
      from  230930b568bb016ed13f0daa70b69922c3f4214a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 35e68591863b7da1698ddc24d8f035fc4c382b9a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Apr 9 19:17:08 2015 +0200

    Fix case of zero length continuation lines in mail parser.
    
    * src/rfc822parse.c (parse_field): Loop after continuation line.
    --
    
    Using header lines like
    
      Name:[lf]
      [space][lf]
      [lf]
    
    resulted in running into the "(s2 = strchr (delimiters2, *s)" branch
    and inserting a new token for the empty continuation line.  This also
    led to one byte read after the string which is what Hanno figured.
    The new code should handle empty continuation lines correct.
    
    Reported-by: Hanno Böck
    Signed-off-by: Werner Koch <wk at gnupg.org>
    
    (backported from gnupg 2.1
     commit 3fbeba64a8bfb2b673230c124a3d616b6568fd2f)

diff --git a/src/rfc822parse.c b/src/rfc822parse.c
index 8d0c5d0..7f643b8 100644
--- a/src/rfc822parse.c
+++ b/src/rfc822parse.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
@@ -105,7 +105,7 @@ length_sans_trailing_ws (const unsigned char *line, size_t len)
 {
   const unsigned char *p, *mark;
   size_t n;
-  
+
   for (mark=NULL, p=line, n=0; n < len; n++, p++)
     {
       if (strchr (" \t\r\n", *p ))
@@ -116,8 +116,8 @@ length_sans_trailing_ws (const unsigned char *line, size_t len)
       else
         mark = NULL;
     }
-  
-  if (mark) 
+
+  if (mark)
     return mark - line;
   return len;
 }
@@ -161,7 +161,7 @@ stpcpy (char *a,const char *b)
   while (*b)
     *a++ = *b++;
   *a = 0;
-  
+
   return (char*)a;
 }
 #endif
@@ -250,7 +250,7 @@ rfc822parse_open (rfc822parse_cb_t cb, void *cb_value)
             {
               release_handle_data (msg);
               free (msg);
-              errno = 0;/* Not meaningful after the callback.  */ 
+              errno = 0;/* Not meaningful after the callback.  */
               msg = NULL;
             }
         }
@@ -357,10 +357,10 @@ transition_to_body (rfc822parse_t msg)
                 {
                   assert (!msg->current_part->boundary);
                   msg->current_part->boundary = malloc (strlen (s) + 1);
-                  if (msg->current_part->boundary) 
+                  if (msg->current_part->boundary)
                     {
                       part_t part;
-                  
+
                       strcpy (msg->current_part->boundary, s);
                       msg->boundary = msg->current_part->boundary;
                       part = new_part ();
@@ -429,7 +429,7 @@ insert_header (rfc822parse_t msg, const unsigned char *line, size_t length)
   hdr->cont = (*line == ' ' || *line == '\t');
   memcpy (hdr->line, line, length);
   hdr->line[length] = 0; /* Make it a string. */
-  
+
   /* Transform a field name into canonical format. */
   if (!hdr->cont && strchr (line, ':'))
      capitalize_header_name (hdr->line);
@@ -491,7 +491,7 @@ insert_body (rfc822parse_t msg, const unsigned char *line, size_t length)
 int
 rfc822parse_insert (rfc822parse_t msg, const unsigned char *line, size_t length)
 {
-  return (msg->in_body 
+  return (msg->in_body
           ? insert_body (msg, line, length)
           : insert_header (msg, line, length));
 }
@@ -517,11 +517,11 @@ rfc822parse_finish (rfc822parse_t msg)
  * WHICH gives the mode:
  *  -1 := Take the last occurence
  *   n := Take the n-th  one.
- * 
+ *
  * Returns a newly allocated buffer or NULL on error.  errno is set in
  * case of a memory failure or set to 0 if the requested field is not
  * available.
- * 
+ *
  * If VALUEOFF is not NULL it will receive the offset of the first non
  * space character in the value part of the line (i.e. after the first
  * colon).
@@ -590,7 +590,7 @@ rfc822parse_enum_header_lines (rfc822parse_t msg, void **context)
   HDR_LINE l;
 
   if (!msg) /* Close. */
-    return NULL;	
+    return NULL;
 
   if (*context == msg || !msg->current_part)
     return NULL;
@@ -761,7 +761,7 @@ parse_field (HDR_LINE hdr)
   static const char tspecials[] = "/?=<>@,;:\\[]\"()";
   static const char tspecials2[] = "/?=<>@.,;:";  /* FIXME: really
                                                      include '.'?*/
-  static struct 
+  static struct
   {
     const unsigned char *name;
     size_t namelen;
@@ -809,10 +809,11 @@ parse_field (HDR_LINE hdr)
   s++; /* Move over the colon. */
   for (;;)
     {
-      if (!*s)
+      while (!*s)
 	{
 	  if (!hdr->next || !hdr->next->cont)
-	    break;
+	    return tok; /* Ready.  */
+          /* Next item is a header continuation line.  */
 	  hdr = hdr->next;
 	  s = hdr->line;
 	}
@@ -825,10 +826,11 @@ parse_field (HDR_LINE hdr)
 	  invalid = 0;
 	  for (s++;; s++)
 	    {
-	      if (!*s)
+	      while (!*s)
 		{
 		  if (!hdr->next || !hdr->next->cont)
 		    break;
+                  /* Next item is a header continuation line.  */
 		  hdr = hdr->next;
 		  s = hdr->line;
 		}
@@ -872,15 +874,16 @@ parse_field (HDR_LINE hdr)
 		  else if (*s2 == '\\' && s2[1]) /* what about continuation? */
 		    s2++;
 		}
-              
+
 	      t = (t
                    ? append_to_token (t, s, s2 - s)
                    : new_token (term == '\"'? tQUOTED : tDOMAINLIT, s, s2 - s));
               if (!t)
                 goto failure;
-                   
+
 	      if (*s2 || !hdr->next || !hdr->next->cont)
 		break;
+              /* Next item is a header continuation line.  */
 	      hdr = hdr->next;
 	      s = hdr->line;
 	    }
@@ -932,8 +935,7 @@ parse_field (HDR_LINE hdr)
 	  s++;
 	}
     }
-
-  return tok;
+  /*NOTREACHED*/
 
  failure:
   {
@@ -1008,10 +1010,10 @@ is_parameter (TOKEN t)
    Returns a pointer to the value which is valid as long as the
    parse context is valid; NULL is returned in case that attr is not
    defined in the header, a missing value is represented by an empty string.
- 
+
    With LOWER_VALUE set to true, a matching field value will be
    lowercased.
- 
+
    Note, that ATTR should be lowercase.  If ATTR is NULL the fucntion
    returns the first token of the field; i.e. not the parameter but
    the actual value.  A CTX of NULL is allowed and will return NULL.
@@ -1134,7 +1136,7 @@ dump_structure (rfc822parse_t msg, part_t part, int indent)
       part_t save_part; /* ugly hack - we should have a function to
                            get part inforation. */
       const char *s;
-      
+
       save_part = msg->current_part;
       msg->current_part = part;
       ctx = rfc822parse_parse_field (msg, "Content-Type", -1);
@@ -1160,7 +1162,7 @@ dump_structure (rfc822parse_t msg, part_t part, int indent)
       if (part->down)
         dump_structure (msg, part->down, indent + 1);
     }
-  
+
 }
 
 

-----------------------------------------------------------------------

Summary of changes:
 src/rfc822parse.c | 54 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list