That encoded[len] reference should use the same apr_base64_encode_len result as the first allocation, or the bas64 data is truncated.
Re: followups: I don’t see a reason for deprecating the separate encoder functions, after adding the useful wrapper. There are enough good reasons why applications depending on apr might want to do their own memory management. Bert Sent from Mail for Windows 10 From: Dirk-Willem van Gulik Sent: donderdag 19 januari 2017 14:23 To: APR Developer List Subject: pool based base64 binary encode Any reason we do not have such in APR-2 (as a compagnion to apr_pbase64_encode) ? Dw. APR_DECLARE(char *) apr_pbase64_encode_binary(apr_pool_t *p, const unsigned char *string, int len) { char *encoded; encoded = (char *) apr_palloc(p, 1 + apr_base64_encode_len(len)); len = apr_base64_encode_binary(encoded, string, len); encoded[len] = '\0'; /* make binary sequence into string */ return encoded; }