Re: [PATCH v2] Let mailsplit and mailinfo handle mails with CRLF line-endings
> Be aware that if we use the version I suggested which pushes the '\r' back
> into the input stream, I think we risk an infinite loop if size == 1. I don't
> think that is possible from the current callers though.
I think something like this would avoid any potential infinite loop, however improbable:
if (c == '\n') {
if (len > 1 && buf[len - 2] == '\r')
buf[--len - 1] = '\n';
} else if (c == '\r') {
c = getc(in);
if (c == '\n')
buf[len - 1] = '\n';
else if (c != EOF)
ungetc(c, in);
}-brandon