[gmime] Handle more malformed addresses



commit 3d6b1511e5828556ae91f63496a82ed397c8cced
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Mon Nov 29 20:36:31 2010 -0500

    Handle more malformed addresses
    
    2010-11-29  Jeffrey Stedfast  <fejj novell com>
    
    	* gmime/internet-address.c (decode_address): Handle edge cases
    	where inptr reaches the end of the input string prematurely due
    to
    	a malformed address.

 ChangeLog                |    6 ++++++
 gmime/internet-address.c |    9 +++++----
 tests/test-mime.c        |    3 +++
 3 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2e2b831..3b93b5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-11-29  Jeffrey Stedfast  <fejj novell com>
 
+	* gmime/internet-address.c (decode_address): Handle edge cases
+	where inptr reaches the end of the input string prematurely due to
+	a malformed address.
+
+2010-11-29  Jeffrey Stedfast  <fejj novell com>
+
 	Fixes bug #635409.
 
 	* gmime/gmime-pkcs7-context.c (pkcs7_get_validity): Reworked the
diff --git a/gmime/internet-address.c b/gmime/internet-address.c
index 73915e1..af60123 100644
--- a/gmime/internet-address.c
+++ b/gmime/internet-address.c
@@ -1392,10 +1392,9 @@ decode_address (const char **in)
 	 * tokens that make up this name phrase.
 	 */
 	while (*inptr) {
-		if ((word = decode_word (&inptr)))
+		if ((word = decode_word (&inptr))) {
 			g_string_append_len (name, word, (size_t) (inptr - word));
-		
-		if (word) {
+			
 		check_lwsp:
 			word = inptr;
 			skip_lwsp (&inptr);
@@ -1450,7 +1449,7 @@ decode_address (const char **in)
 		} else if (*inptr == '(') {
 			/* beginning of a comment, use decode_lwsp() to skip past it */
 			decode_lwsp (&inptr);
-		} else if (strchr ("@,;", *inptr)) {
+		} else if (*inptr && strchr ("@,;", *inptr)) {
 			if (name->len == 0) {
 				if (*inptr == '@') {
 					GString *domain;
@@ -1505,6 +1504,8 @@ decode_address (const char **in)
 			inptr++;
 			
 			goto check_lwsp;
+		} else {
+			goto addrspec;
 		}
 	}
 	
diff --git a/tests/test-mime.c b/tests/test-mime.c
index 49962e6..af30c7f 100644
--- a/tests/test-mime.c
+++ b/tests/test-mime.c
@@ -191,6 +191,9 @@ static struct {
 	{ "\"=?ISO-8859-2?Q?TEST?=\" <p p org>",
 	  "TEST <p p org>",
 	  "TEST <p p org>" },
+	{ "sdfasf wp pl,c tert wp pl,sffdg rtre op pl",
+	  "sdfasf wp pl, c, sffdg rtre op pl",
+	  "sdfasf wp pl, c, sffdg rtre op pl" },
 };
 
 static struct {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]