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

Resume partial writes in gnutls_bye() #596

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

brozs
Copy link

@brozs brozs commented Jul 27, 2020

This pull request should make lftp resume partial writes that happen in gnutls_bye() on SSL shutdown.

A partial write on SSL shutdown can cause problems with some FTPS servers, e.g. IIS on Windows.

This is my first pull request to lftp, any feedback welcome.

src/lftp_ssl.cc Outdated
if(handshake_done)
gnutls_bye(session,GNUTLS_SHUT_RDWR); // FIXME - E_AGAIN
res=gnutls_bye(session,GNUTLS_SHUT_RDWR);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move declaration of res here, it's better to declare in a more local scope where it is used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean:

Suggested change
res=gnutls_bye(session,GNUTLS_SHUT_RDWR);
int res=gnutls_bye(session,GNUTLS_SHUT_RDWR);

And remove int res; from the top of lftp_ssl_gnutls::shutdown()?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right

src/lftp_ssl.cc Show resolved Hide resolved
src/lftp_ssl.cc Outdated
{
int res;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int res;

@brozs
Copy link
Author

brozs commented Oct 21, 2020

Forced push based on your feedback.

@@ -42,7 +42,7 @@ int IOBufferSSL::Do()
if(Put_LL("",0)<0)
return MOVED;
if(ssl->handshake_done && eof)
ssl->shutdown();
PutEOF_LL();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use return value?

@@ -340,10 +340,22 @@ void lftp_ssl_gnutls::load_keys()
}
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
}
void lftp_ssl_gnutls::shutdown()
int lftp_ssl_gnutls::shutdown()
{
if(handshake_done)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opening brace?

Co-authored-by: Štěpán Brož <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants