Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POP3Client.prototype.uidl - infinite loop #1

Closed
nazar opened this issue Nov 2, 2011 · 2 comments
Closed

POP3Client.prototype.uidl - infinite loop #1

nazar opened this issue Nov 2, 2011 · 2 comments

Comments

@nazar
Copy link

nazar commented Nov 2, 2011

Hi Ditesh.

Thank you for the library.

I've encountered a situation where POP3Client.prototype.uidl get stuck in a loop.

                        while(true) {

                            if ( (offset > endOffset) break;

                            newoffset = data.indexOf("\r\n", offset);
                            listitem = data.substr(offset, newoffset-offset);
                            listitem = listitem.split(" ");
                            returnValue[listitem[0]] = listitem[1];
                            offset = newoffset + 2;

                        }

the (offset > endOffSet) is never met as when the last item is added offset is smaller than endOffset.

I patched it as follows:

                        while(true) {

                            if ( (offset > endOffset) || (newoffset == -1) ) break;

                            newoffset = data.indexOf("\r\n", offset);
                            listitem = data.substr(offset, newoffset-offset);
                            listitem = listitem.split(" ");
                            returnValue[listitem[0]] = listitem[1];
                            offset = newoffset + 2;

                        }

There might be a better way.

HTH

ditesh added a commit that referenced this issue Nov 8, 2011
@ditesh
Copy link
Owner

ditesh commented Nov 8, 2011

Thanks for the feedback. I've committed a fix.

Could you help test out commit 269e36f ?

@ditesh
Copy link
Owner

ditesh commented Nov 8, 2011

Released 0.1.4, with several other fixes.

@ditesh ditesh closed this as completed Nov 8, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants