[BusyBox] [PATCH] uuencode and binary data
Pascal Brisset
pascal.brisset at wanadoo.fr
Sun Jan 25 01:54:08 UTC 2004
uuencode fails to encode binary data because it right-shifts
bytes as signed chars and keeps the duplicated sign bits.
The original base64_encode() from wget/http.c is broken as well,
but it is only used to encode ascii data.
-- Pascal
--- busybox-1.00-pre5/coreutils/uuencode.c.orig 2004-01-25 02:17:52.578082520 +0100
+++ busybox-1.00-pre5/coreutils/uuencode.c 2004-01-25 02:19:21.753525792 +0100
@@ -55,15 +55,15 @@
/*
* Encode the string S of length LENGTH to base64 format and place it
* to STORE. STORE will be 0-terminated, and must point to a writable
* buffer of at least 1+BASE64_LENGTH(length) bytes.
* where BASE64_LENGTH(len) = (4 * ((LENGTH + 2) / 3))
*/
-static void uuencode (const char *s, const char *store, const int length, const char *tbl)
+static void uuencode (const unsigned char *s, const char *store, const int length, const char *tbl)
{
int i;
unsigned char *p = (unsigned char *)store;
/* Transform the 3x8 bits to 4x6 bits, as required by base64. */
for (i = 0; i < length; i += 3) {
*p++ = tbl[s[0] >> 2];
More information about the busybox
mailing list