]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
rustls: remove incorrect EOF check
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>
Sat, 13 Nov 2021 02:18:41 +0000 (18:18 -0800)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 13 Nov 2021 21:57:20 +0000 (22:57 +0100)
The update to rustls-ffi 0.8.0 changed handling of EOF and close_notify.
From the CHANGELOG:

> Handling of unclean close and the close_notify TLS alert. Mirroring
> upstream changes, a rustls_connection now tracks TCP closed state like
> so: rustls_connection_read_tls considers a 0-length read from its
> callback to mean "TCP stream was closed by peer."  If that happens
> before the peer sent close_notify, rustls_connection_read will return
> RUSTLS_RESULT_UNEXPECTED_EOF once the available plaintext bytes are
> exhausted. This is useful to protect against truncation attacks. Note:
> some TLS implementations don't send close_notify. If you are already
> getting length information from your protocol (e.g. Content-Length in
> HTTP) you may choose to ignore UNEXPECTED_EOF so long as the number of
> plaintext bytes was as expected.

That means we don't need to check for unclean EOF in `cr_recv()`,
because `process_new_packets()` will give us an error if appropriate.

Closes #8003

lib/vtls/rustls.c

index 381737e599ecb98fa7631dcf4e91647ff07c1693..76519b2aefcdc723ac0bd067ab52d65fac9dd361 100644 (file)
@@ -138,11 +138,6 @@ cr_recv(struct Curl_easy *data, int sockindex,
     *err = CURLE_READ_ERROR;
     return -1;
   }
-  else if(tls_bytes_read == 0) {
-    failf(data, "connection closed without TLS close_notify alert");
-    *err = CURLE_READ_ERROR;
-    return -1;
-  }
 
   infof(data, "cr_recv read %ld bytes from the network", tls_bytes_read);