Hello list,

I encountered a couple of problems with base64 uudecode. It couldn't
handle an empty file (term_count needs to be 1 at the beginning of a
line to catch the terminating line, which it was for every line but
the first) and when the output was supposed to be 3n+1 bytes it wrote
an extra junk byte at the end when it encountered the second '='. The
patch below should fix both issues.

   Jörgen


Index: coreutils/uudecode.c
===================================================================
--- coreutils/uudecode.c        (revision 18719)
+++ coreutils/uudecode.c        (working copy)
@@ -70,7 +70,7 @@
 {
        static const char base64_table[] =
                
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n";
-       int term_count = 0;
+       int term_count = 1;
 
        while (1) {
                char translated[4];
@@ -113,7 +113,9 @@
                }
 
                /* Merge 6 bit chars to 8 bit */
-           fputc(translated[0] << 2 | translated[1] >> 4, dst_stream);
+               if (count > 1) {
+                       fputc(translated[0] << 2 | translated[1] >> 4, 
dst_stream);
+               }
                if (count > 2) {
                        fputc(translated[1] << 4 | translated[2] >> 2, 
dst_stream);
                }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to