Skip to content

Commit

Permalink
Redo patch for corecode#43 on branch from master (so it can be indepe…
Browse files Browse the repository at this point in the history
…ndently reviewed from corecode#18 changes).
  • Loading branch information
n0gOoi3 committed Aug 1, 2016
1 parent 17a0f39 commit b1c82f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ int
readmail(struct queue *queue, int nodot, int recp_from_header)
{
struct parse_state parse_state;
char line[1000]; /* by RFC2822 */
char line[1000+1]; /* by RFC2822 (and allow fgets to append '\0') */
size_t linelen;
size_t error;
int had_headers = 0;
Expand Down Expand Up @@ -379,12 +379,14 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
" from %s (uid %d) (envelope-from %s)",
username, useruid, queue->sender);
linelen = strlen(line);
if (linelen == 0 || line[linelen - 1] != '\n') {
if (linelen == 0 || line[linelen - 2] != '\r' || line[linelen - 1] != '\n' ) {
/*
* This line did not end with a newline character.
* This line did not end with a CRLF, cludge it.
* If we fix it, it better be the last line of
* the file.
* XXX: overwriting valid input is probably inadequate
*/
line[linelen-1] = '\r';
line[linelen] = '\n';
line[linelen + 1] = 0;
had_last_line = 1;
Expand Down

0 comments on commit b1c82f9

Please sign in to comment.