Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/usr.bin
Christos Zoulas wrote in <pj8s50$v1e$1%blaine.gmane.org@localhost>:
|In article <20180724185738.GA15885%britannica.bec.de@localhost>,
|Joerg Sonnenberger <joerg%bec.de@localhost> wrote:
|>
|>Why do we need another base64 encoder/decoder?
|
|So I've been looking into how to get rid of it and re-use uuencode
|uudecode for it and it is proving difficult. I am trying to provide
|a command line compatible utility with the "base64" command from
|MacOS/X and Linux:
|
|- They use a single command to encode and decode (uuencode and decode
| are two separate programs). I would have to either write a shell
| script front end (and modify them not to output a header) to be
| able to emulate that.
|- uudecode is using b64_pton() which does not handle arbitrary whitespace.
To me the difference in between "openssl base64" and Linux base64
is that the latter can deal with invalid base64, as is indeed not
uncommon in mail message parts. MUAs like mutt (or my one) can
deal with this, but they of course operate in the MIME
surroundings. For example, comparing busybox base64 and NetBSD
base64.c from yesterday (after getting rid of __dead and
getprogname()):
#?0[steffen@essex tmp]$ base64 -d <x|wc -l
49
#?0[steffen@essex tmp]$ tcc -run base64.c -d < x |wc -l
In file included from base64.c:32:
/usr/include/sys/cdefs.h:1: warning: #warning usage of non-standard #include <sys/cdefs.h> is deprecated
tcc: Decoding failed
13
This is caused by an exclamation mark at the end of the first
line, which is 990 bytes. (The data is an excerpt from a mail
that has been sent to IANA tz in April 2015.)
In comparison, complete frustration with LibreSSL and OpenSSL:
#?0[steffen@essex tmp]$ openssl base64 -d <x |wc -l
0
#?0[steffen@essex tmp]$ ~/usr-essex-alpine-linux-x86_64/opt/.ossl-1.1.1/bin/openssl base64 -d <x |wc -l
0
The busybox base64 does this by "Get next _valid_ character" in
libbb/uuencode.c (whereas i break my head to do this, sic):
while (count < 4) {
char *table_ptr;
...
do {
ch = *src;
..
table_ptr = strchr(bb_uuenc_tbl_base64, ch);
//TODO: add BASE64_FLAG_foo to die on bad char?
} while (!table_ptr);
...
}
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Home |
Main Index |
Thread Index |
Old Index