dma: restore addition of newline when missing from input
If input mail does not have a newline on the last line dma must add
one. This was broken by the addition of long-line splitting, with the
switch from strlen(line) to linelen returned by getline().
PR: 266629
Reviewed by: bapt, Mikko Lehto
Tested by: Mikko Lehto
MFC after: 1 week
Fixes: b0b2d05fd0
("Split body of mails not respecting...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36763
This commit is contained in:
parent
b58094c0d9
commit
1694872231
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <malloc_np.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -418,8 +419,14 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
|
|||||||
* If we fix it, it better be the last line of
|
* If we fix it, it better be the last line of
|
||||||
* the file.
|
* the file.
|
||||||
*/
|
*/
|
||||||
line[linelen] = '\n';
|
if ((size_t)linelen + 1 > linecap) {
|
||||||
line[linelen + 1] = 0;
|
line = realloc(line, linelen + 2);
|
||||||
|
if (line == NULL)
|
||||||
|
errlogx(EX_SOFTWARE, "realloc");
|
||||||
|
linecap = malloc_usable_size(line);
|
||||||
|
}
|
||||||
|
line[linelen++] = '\n';
|
||||||
|
line[linelen] = 0;
|
||||||
had_last_line = 1;
|
had_last_line = 1;
|
||||||
}
|
}
|
||||||
if (!had_first_line) {
|
if (!had_first_line) {
|
||||||
|
Loading…
Reference in New Issue
Block a user