[Users] [Bug 4728] New: socket: handle GNUTLS_E_PREMATURE_TERMINATION in ssl_read

noreply at thewildbeast.co.uk noreply at thewildbeast.co.uk
Sun Jan 7 15:05:22 UTC 2024


https://www.thewildbeast.co.uk/claws-mail/bugzilla/show_bug.cgi?id=4728

            Bug ID: 4728
           Summary: socket: handle GNUTLS_E_PREMATURE_TERMINATION in
                    ssl_read
           Product: Claws Mail (GTK 2)
           Version: GIT
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Other
          Assignee: users at lists.claws-mail.org
          Reporter: olaf at aepfle.de

Created attachment 2386
  -->
https://www.thewildbeast.co.uk/claws-mail/bugzilla/attachment.cgi?id=2386&action=edit
gtk2-socket-handle-GNUTLS_E_PREMATURE_TERMINATION-in-ssl_.patch

The function gnutls_record_recv can receive all data without error only if the
receive buffer is large enough for a single read.

In case the data will be received in chunks into a smaller receive buffer, to
process each chunk individually, then it may happen that gnutls_record_recv
returns the error GNUTLS_E_PREMATURE_TERMINATION. This happens for example with
a HTPPS connection, which was established with "Connection: close". In this
case the remote side will transmit all data, and closes the connection, as
requested. Once gnutls_record_recv processed all data, and nothing more is to
read, it will detect the closed connection and returns the error above -
instead returning read
size zero to indicate EOF to the caller.

One way to handle this case is to check errno. Usually read() and recv() return
0 in case of EOF, without setting errno. This behavior is used to return from
ssl_read without error.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Users mailing list