curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Decoding base64 in parameter parsing

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 3 Sep 2018 08:02:01 +0200 (CEST)

On Mon, 3 Sep 2018, Philipp Hagemeister via curl-library wrote:

> /usr/bin/ld: curl-tool_getparam.o: in function `getparameter':
> tool_getparam.c:(.text+0x2f2f): undefined reference to `Curl_base64_decode'
>
> I can now reproduce the problem, but I'm not sure how I did manage to build
> a working version of curl with my changes (it even passed the automated and
> a number of manual tests I did!).

Maybe because of a debug build that inhibits the hiding of symbols (for unit
test purposes) ?

> 3) Curl_base64_decode is (rightly) not part of the public libcurl API, or is
> it?

No it isn't. The uppercase 'C' gives that away. Only 'curl_' prefixed
functions (that have protos in the include/curl/*.h headers) are part of the
API.

> 4) curlx seems to be made for these cases, but I'm not sure how to properly
> configure that. If I just add base64.c to CURLX_CFILES in Makefile.inc, the
> linker is missing Curl_cmalloc . How do I get _that_?

curlx is the system we use to allow the command line tool to reuse code from
the library, without using the API. But curlx functions then need to not use
non-curlx functions or other private libcurl structs, otherwise we can't just
use that single file. base64.c is one of those files that have not been
designed to easily get converted to a curlx file. Primarily because of the
call to Curl_convert_clone() in there.

> 5) I could switch from base64 to another encoding, such as URL-encoding.
> Maybe that's simpler to parse. But base64 seems best for binary data
> ("only" 1/3 overhead).

If there's a lot of non-ascii bytes, then base64 certainly is more compact...

> 6) Is there any other option?

I suppose a format like this is only really sensible if you can find tools
that can output data in this format, and then even url encoding is difficult.

In the PR you mention a concern that 'base64' is not available on Windows - so
how do you expect most windows users to use a command line option that takes
base64 encoded data?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-09-03