An hidden bug that could bring problems, pop3_readline ()
was doing the equivalent of: char buffer[1024]; memset (buffer, 0, 1024); ... read (popfd, buffer, 1024); ... ret = malloc (strlen (buffer) +1); According to the rfc a command line should be no longer then 255 but a malicious client could send a big buffer that could fit 1024 then buffer would not be null terminated, strlen(buffer) may be supceptible to overflow. A simple fix would be to read (fd, buffer, 1023); /* leave space for a null */ I've put a different fix that does not need the call to memset(). And at the same time reduce the size of the buffer to go easy on the stack 512 is sufficient.
Showing
1 changed file
with
8 additions
and
5 deletions
-
Please register or sign in to post a comment