BASE64: - By Edward Flick - 0-terminate the transcoded buffer
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 2 Jan 2014 23:41:06 +0000 (00:41 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 2 Jan 2014 23:41:06 +0000 (00:41 +0100)
libcitadel/lib/tools.c

index d539619..fa8f165 100644 (file)
@@ -324,13 +324,14 @@ size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int li
                        dest[destoffset++] = '\r';
                        dest[destoffset++] = '\n';
                }
-               return destoffset;
-
-       } else {
+       }
+       else {
                destoffset = base64_encode_block(source, sourcelen, dest, &_state);
 
-               return destoffset + base64_encode_blockend(&(dest[destoffset]), &_state);
+               destoffset += base64_encode_blockend(&(dest[destoffset]), &_state);
        }
+       dest[destoffset] = 0;
+       return destoffset;
 }