nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inc and non-compliant long lines redux


From: Ken Hornstein
Subject: Re: inc and non-compliant long lines redux
Date: Wed, 16 Nov 2022 13:45:07 -0500

Following up to myself ...

Since Ralph mentioned fetchmail, I was curious what it does when confronted
with a huge-assed line.  Here's what I found in transact.c:

            /*
             * Try to gracefully handle the case where the length of a
             * line exceeds MSGBUFSIZE.
             */
            if (n && buf[n-1] != '\n') 
            {
                rline = (char *) realloc(line, linelen + 1);
                if (rline == NULL)
                {
                    free (line);
                    return(PS_IOERR);
                }
                line = rline;
                memcpy(line + linelen - n, buf, n);
                line[linelen] = '\0';
                ch = ' '; /* So the next iteration starts */
                continue;
            }

Which ... is a little confusing in the overall loop.  But ... the way
I read it is that "line" is realloc()d to be larger, existing data is copied
into "line" and then it keeps going.  So with Andy's email, he'd end up
with an 11MB buffer being allocated.  I don't QUITE think that is required
(see previous emails) and it's entirely possible I am reading the overall
loop wrong.  But it doesn't just give up, that's for sure; it deals.

As an aside, fetchmail uncerimoniously smashes all NULs that it finds.
Seems like a reasonable policy to me.

--Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]