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

ftplib::Login bad logic ? #9

Open
erakis opened this issue Nov 2, 2016 · 0 comments
Open

ftplib::Login bad logic ? #9

erakis opened this issue Nov 2, 2016 · 0 comments

Comments

@erakis
Copy link

erakis commented Nov 2, 2016

Hi,

What is the logic behind this

int ftplib::Login(const char *user, const char *pass)
{
	char tempbuf[64];

	if (((strlen(user) + 7) > sizeof(tempbuf)) || ((strlen(pass) + 7) > sizeof(tempbuf))) return 0;
	sprintf(tempbuf, "USER %s", user);
	if (!FtpSendCmd(tempbuf,'3',mp_ftphandle))
	{
		if (mp_ftphandle->ctrl != NULL) return 1;
// ------>	if (*LastResponse() == '2') return 1; 
// <------------ HERE, is it to test for anonymous login ?
		return 0;
	}
	sprintf(tempbuf,"PASS %s",pass);
	return FtpSendCmd(tempbuf,'2',mp_ftphandle);
}

If we are losing the connection between the connect but before the Login operation this condition will be true and login function will return 1 (succeed) instead of returning 0 (failed) even if network are now down. If we remove this condition, the logic is going to be right.

What about removing this condition and leting the user use the Login function even if it was accepted as anonymous ?

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

1 participant