Are you using str[n]cpy? You can’t! Base64 encoded data can contain null characters, which C string processing functions interpret as end-of-string.
Use memcpy instead of str[n]cpy, memcmp instead of strcmp, etc. These functions require you to know your data size, but I believe that you do know it.
Also if you’re not very confident about C-style strings and such, there’s plenty of information to be found about the topic here.
2
solved Base64 decoding – incorrect string length