t--;
}
/* Replace a single \n or \r with \r\n */
- if (*h == '\n' && h != *start && *(h - 1) != '\r') {
+ if (*h == '\n' && (h == *start || *(h - 1) != '\r')) {
*t++ = '\r';
inlen--;
added ++;
while (len && inlen) {
if (*h == '\r' || *h == '\n') {
/* Replace a single \n or \r with \r\n */
- if (*h == '\n' && *(h - 1) != '\r') {
+ if (*h == '\n' && (h == *start || *(h - 1) != '\r')) {
*t++ = '\r';
added ++;
inlen--;
}
}
end = p + 1;
- if (end == start || end == start + 2) {
+ if (end == start) {
/* Empty body */
if (ctx->body_canon_type == DKIM_CANON_SIMPLE) {
g_checksum_update (ctx->body_hash, CRLF, sizeof (CRLF) - 1);