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::FtpClose - please add NULL pointer checking, otherwise unwanted crash may occur. #16

Open
Fojtik opened this issue Dec 1, 2016 · 0 comments

Comments

@Fojtik
Copy link

Fojtik commented Dec 1, 2016

When NULL is not checked, passing NULL pointer causes crash when attempting to dereference nData->dir. As far as int FtpClose(ftphandle *nData); is not internal function, the argument passed cannot be guaranteed.

/*
 * FtpClose - close a data connection
 */
int ftplib::FtpClose(ftphandle *nData)
{
	ftphandle *ctrl;

	if (nData->dir == FTPLIB_WRITE)
	{
		if (nData->buf != NULL) writeline(NULL, 0, nData);
	}
	else if (nData->dir != FTPLIB_READ) return 0;
	if (nData->buf) free(nData->buf);
	shutdown(nData->handle,2);
	net_close(nData->handle);

Please add NULL pointer checking here:

/*
 * FtpClose - close a data connection
 */
int ftplib::FtpClose(ftphandle *nData)
{
  ftphandle *ctrl;

  if (nData==NULL) return 0;
  if (nData->dir == FTPLIB_WRITE)
  {
    if (nData->buf != NULL) writeline(NULL, 0, nData);
  }
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