[PATCH RESEND] bug fix incremental base64 encoding (glib)



If the previous incremental encoding saved two bytes, the followed-up
incremental just one and we than call the finish routine than state
looks like '01-XX-YY-00' where XX is the actual saved c1 and YY and c2
saved from the last previous (not last) incremental encoding. Since c2
is not zero now, we get a bogus result.

Signed-off-by Sebastian Siewior <sebastian breakpoint cc>
---
Bug available in Revision 7055 @
http://svn.gnome.org/svn/glib/trunk/glib/

--- a/glib/gbase64.c    2008-06-14 13:45:43.700994494 +0200
+++ b/glib/gbase64.c    2008-06-14 14:21:22.610015263 +0200
@@ -182,15 +182,16 @@
   g_return_val_if_fail (save != NULL, 0);

   c1 = ((unsigned char *) save) [1];
-  c2 = ((unsigned char *) save) [2];

   switch (((char *) save) [0])
     {
     case 2:
+      c2 = ((unsigned char *) save) [2];
       outptr [2] = base64_alphabet[ ( (c2 &0x0f) << 2 ) ];
       g_assert (outptr [2] != 0);
       goto skip;
     case 1:
+      c2 = 0;
       outptr[2] = '=';
     skip:
       outptr [0] = base64_alphabet [ c1 >> 2 ];



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