Awesome sauce, read description below for details.
My 'ctdlload' operation kept failing because there were a few user
records dumped that had insane data in them. CtdlDecodeBase64() was
silently doing buffer overruns because it doesn't know the size of
the target buffer.
While noodling a workaround, I realized that you can pass the same
pointer to CtdlDecodeBase64() as both the source *and* target buffer.
This works because the decoded data pointer will ALWAYS be behind the
encoded data pointer. This allows a "decode-in-place" operation!
By performing a decode-in-place and then using safestrncpy() to copy
the results to the finitely-sized string buffer in the target struct,
we guarantee no buffer overruns. Valgrind no longer bitches about it
and the program does not crash.