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

gEDA-cvs: branch: master updated (1.1.2.20070818-38-g2395379)



The branch, master has been updated
       via  23953797984fda7cb62dceef38ac26da25c2dcd2 (commit)
      from  613dcf8d3c2cf0ef40278ff481cc44e68c98428a (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.


=========
 Summary
=========

 libgeda/src/o_picture.c  |    2 +-
 libgeda/src/s_encoding.c |   14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)


=================
 Commit Messages
=================

commit 23953797984fda7cb62dceef38ac26da25c2dcd2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Sep 5 18:39:55 2007 +0100

    Fix loading of embedded images.
    
    Various bugs in the base64 decoding function were preventing the correct
    decoding of the embedded image. In addition, it was possible for this code
    to access invalid memory - possibly leading to a crash.
    
    Additionally removes extra \n inserted between lines of the base64 input.

:100644 100644 d7c1745... a5c7406... M	libgeda/src/o_picture.c
:100644 100644 f92d742... c1df554... M	libgeda/src/s_encoding.c

=========
 Changes
=========

commit 23953797984fda7cb62dceef38ac26da25c2dcd2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Sep 5 18:39:55 2007 +0100

    Fix loading of embedded images.
    
    Various bugs in the base64 decoding function were preventing the correct
    decoding of the embedded image. In addition, it was possible for this code
    to access invalid memory - possibly leading to a crash.
    
    Additionally removes extra \n inserted between lines of the base64 input.

diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c
index d7c1745..a5c7406 100644
--- a/libgeda/src/o_picture.c
+++ b/libgeda/src/o_picture.c
@@ -167,7 +167,6 @@ OBJECT *o_picture_read(TOPLEVEL *toplevel, OBJECT *object_list,
 
       if (g_strcasecmp(line, ".\n") != 0) {
 	encoded_picture=g_string_append (encoded_picture, line);
-	encoded_picture=g_string_append (encoded_picture, "\n");
       }
       else {
 	finished = 1;
@@ -178,6 +177,7 @@ OBJECT *o_picture_read(TOPLEVEL *toplevel, OBJECT *object_list,
     pixdata_serialized_data=s_encoding_base64_decode(encoded_picture->str,
 						     encoded_picture->len,
 						     &pixdata_serialized_length);
+
     if (pixdata_serialized_data == NULL) {
       fprintf(stderr, "Error decoding picture.\n");      
       s_log_message ("Error decoding picture.\n");
diff --git a/libgeda/src/s_encoding.c b/libgeda/src/s_encoding.c
index f92d742..c1df554 100644
--- a/libgeda/src/s_encoding.c
+++ b/libgeda/src/s_encoding.c
@@ -204,13 +204,14 @@ gchar *s_encoding_base64_decode (gchar* src, guint srclen, guint* dstlenp)
   dst = g_new(gchar, srclen+1);
   *dstlenp = srclen+1;
 
-  while (srclen-- > 0) 
+  while (srclen > 0)
     {
+      srclen--;
       ch = *src++;
-      if (s_encoding_Base64_rank[ch]==255) /* Skip any non-base64 anywhere */
-	continue;
       if (ch == s_encoding_Pad64) 
 	break;
+      if (s_encoding_Base64_rank[ch]==255) /* Skip any non-base64 anywhere */
+	continue;
 
       pos = s_encoding_Base64_rank[ch];
 
@@ -266,9 +267,11 @@ gchar *s_encoding_base64_decode (gchar* src, guint srclen, guint* dstlenp)
 	  return NULL;
 	case 2:             /* Valid, means one byte of info */
                                 /* Skip any number of spaces. */
-	  while (srclen-- > 0) 
+	  while (srclen > 0)
 	    {
+	      srclen--;
 	      ch = *src++;
+	      if (ch == s_encoding_Pad64) break;
 	      if (s_encoding_Base64_rank[ch] != 255) break;
 	    }
                                 /* Make sure there is another trailing = sign. */
@@ -284,8 +287,9 @@ gchar *s_encoding_base64_decode (gchar* src, guint srclen, guint* dstlenp)
                                  * We know this char is an =.  Is there anything but
                                  * whitespace after it?
                                  */
-	  while (srclen-- > 0) 
+	  while (srclen > 0)
 	    {
+	      srclen--;
 	      ch = *src++;
 	      if (s_encoding_Base64_rank[ch] != 255) 
 		{




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs