Ticket #1486010 (closed Bugs: fixed)
Endless loop in imap.inc
| Reported by: | denver | Owned by: | |
|---|---|---|---|
| Priority: | 5 | Milestone: | 0.3-stable |
| Component: | IMAP connection | Version: | 0.2.2 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
My server has courier-imap installed and the latest stable release of roundcube.
I have noticed that when logging in with and invalid e-mail user (eg. sjbdsakashd@…) , roundcube hangs indefinitely and spikes up to 100% CPU and stays there.
After a closer look at function iil_C_Login i see that the while loop waits for a line starting with: "a001" or for $line to be "false" in order to end.
The login string is sent by this line:
iil_PutLine($conn->fp, 'a001 LOGIN "'.iil_Escape($user).'" "'.iil_Escape($password).'"');
and when using a correct login and password, courier-imap returns exactly what the loop needs to end:
# telnet localhost 143 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information. a001 LOGIN gaby@samfira.com **password** a001 OK LOGIN Ok.
$line starts with a001 and the loop ends.
However, when using invalid user data, courier-imap hangs for a few seconds and returns:
# telnet localhost 143 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information. a001 LOGIN sadgjasdgja iasudiasfughs * BYE Temporary problem, please try again later
It seems that $line returns an EMPTY string and the loop never ends.
In order to stop roundcube from overwhelming my system i had to write in a counter for the while loop that breaks after 1 try. This way after about 20 seconds the loop breaks and an error message is returned to the user.
Valid logins work ok. Im sure there is an easier and cleaner way to do this, but if i can be of any further help, please let me know.
