it encodes. This is what broke listsub and probably other things as well.
I deliberately changed the calling syntax of base64_encode_blockend() to make
it break if someone tries to upgrade it later, so it will call their attention
to this difference.
-/*
-cencoder.c - c source to a base64 encoding algorithm implementation
-
-This is part of the libb64 project, and has been placed in the public domain.
-For details, see http://sourceforge.net/projects/libb64
-*/
+//
+// cencoder.c - c source to a base64 encoding algorithm implementation
+//
+// This is part of the libb64 project, and has been placed in the public domain.
+// For details, see http://sourceforge.net/projects/libb64
+//
+// ** NOTE: MODIFIED BY AJC 2016JAN22 **
+// The libb64 distribution always places a newline at the end of an encoded block.
+// We have removed that behavior. If libb64 is updated, make that change again.
+//
+//
return codechar - code_out;
}
return codechar - code_out;
}
-int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
+int base64_encode_blockend(char* code_out, base64_encodestate* state_in, int with_newline)
{
char* codechar = code_out;
{
char* codechar = code_out;
- *codechar++ = '\r';
- *codechar++ = '\n';
+ if (with_newline) { // added by ajc on 2016jan22, normally citadel doesn't want this
+ *codechar++ = '\r';
+ *codechar++ = '\n';
+ }
return codechar - code_out;
}
return codechar - code_out;
}
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in);
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in);
-int base64_encode_blockend(char* code_out, base64_encodestate* state_in);
+int base64_encode_blockend(char* code_out, base64_encodestate* state_in, int with_newline);
#endif /* BASE64_CENCODE_H */
#endif /* BASE64_CENCODE_H */
dest[destoffset++] = '\n';
}
dest[destoffset++] = '\n';
}
- destoffset += base64_encode_blockend(&(dest[destoffset]), &_state);
+ destoffset += base64_encode_blockend(&(dest[destoffset]), &_state, 0);
}
else {
destoffset = base64_encode_block(source, sourcelen, dest, &_state);
}
else {
destoffset = base64_encode_block(source, sourcelen, dest, &_state);
- destoffset += base64_encode_blockend(&(dest[destoffset]), &_state);
+ destoffset += base64_encode_blockend(&(dest[destoffset]), &_state, 0);
}
dest[destoffset] = 0;
return destoffset;
}
dest[destoffset] = 0;
return destoffset;