[evolution-data-server] Fixed uudecode logic



commit 75485b7f2d34f76805c722764f7ac3728f61395f
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Mon Aug 2 12:24:29 2010 -0400

    Fixed uudecode logic
    
    2010-08-02  Jeffrey Stedfast  <fejj novell com>
    
    	Possible fix for bug #625448
    
    	* camel/camel-mime-utils.c (camel_uudecode_step): Properly decrement
    	uulen in the cases where uulen <= 2. Also simplified eoln logic.

 camel/camel-mime-utils.c |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 79a6d22..9db2324 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -269,21 +269,23 @@ camel_uudecode_step (guchar *in, gsize len, guchar *out, gint *state, guint32 *s
 
 	inend = in + len;
 	outptr = out;
-
 	inptr = in;
+
 	while (inptr < inend) {
-		if (*inptr == '\n' || last_was_eoln) {
-			if (last_was_eoln && *inptr != '\n') {
-				uulen = CAMEL_UUDECODE_CHAR (*inptr);
-				last_was_eoln = FALSE;
-				if (uulen == 0) {
-					*state |= CAMEL_UUDECODE_STATE_END;
-					break;
-				}
-			} else {
-				last_was_eoln = TRUE;
+		if (*inptr == '\n') {
+			last_was_eoln = TRUE;
+			
+			inptr++;
+			continue;
+		} else if (!uulen || last_was_eoln) {
+			/* first octet on a line is the uulen octet */
+			uulen = CAMEL_UUDECODE_CHAR (*inptr);
+			last_was_eoln = FALSE;
+			if (uulen == 0) {
+				*state |= CAMEL_UUDECODE_STATE_END;
+				break;
 			}
-
+			
 			inptr++;
 			continue;
 		}
@@ -307,18 +309,21 @@ camel_uudecode_step (guchar *in, gsize len, guchar *out, gint *state, guint32 *s
 					*outptr++ = CAMEL_UUDECODE_CHAR (b0) << 2 | CAMEL_UUDECODE_CHAR (b1) >> 4;
 					*outptr++ = CAMEL_UUDECODE_CHAR (b1) << 4 | CAMEL_UUDECODE_CHAR (b2) >> 2;
 					*outptr++ = CAMEL_UUDECODE_CHAR (b2) << 6 | CAMEL_UUDECODE_CHAR (b3);
+					uulen -= 3;
 				} else {
 					if (uulen >= 1) {
 						*outptr++ = CAMEL_UUDECODE_CHAR (b0) << 2 | CAMEL_UUDECODE_CHAR (b1) >> 4;
+						uulen--;
 					}
+					
 					if (uulen >= 2) {
 						*outptr++ = CAMEL_UUDECODE_CHAR (b1) << 4 | CAMEL_UUDECODE_CHAR (b2) >> 2;
+						uulen--;
 					}
 				}
 
 				i = 0;
 				saved = 0;
-				uulen -= 3;
 			}
 		} else {
 			break;



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