]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ngtcp2: stop buffering crypto data
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Thu, 26 Aug 2021 12:20:52 +0000 (21:20 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Aug 2021 14:31:59 +0000 (16:31 +0200)
Stop buffering crypto data because libngtcp2 now buffers submitted
crypto data.

Closes #7637

lib/vquic/ngtcp2.c
lib/vquic/ngtcp2.h

index 7f074eaefc20dbd1211055d065fc4068a3aa1cfb..16f4d66c10f3f23488d4a1b03531b64b059628b9 100644 (file)
@@ -190,27 +190,9 @@ static int write_client_handshake(struct quicsocket *qs,
                                   ngtcp2_crypto_level level,
                                   const uint8_t *data, size_t len)
 {
-  struct quic_handshake *crypto_data;
   int rv;
 
-  crypto_data = &qs->crypto_data[level];
-  if(!crypto_data->buf) {
-    crypto_data->buf = malloc(4096);
-    if(!crypto_data->buf)
-      return 0;
-    crypto_data->alloclen = 4096;
-  }
-
-  /* TODO Just pretend that handshake does not grow more than 4KiB for
-     now */
-  assert(crypto_data->len + len <= crypto_data->alloclen);
-
-  memcpy(&crypto_data->buf[crypto_data->len], data, len);
-  crypto_data->len += len;
-
-  rv = ngtcp2_conn_submit_crypto_data(
-    qs->qconn, level, (uint8_t *)(&crypto_data->buf[crypto_data->len] - len),
-    len);
+  rv = ngtcp2_conn_submit_crypto_data(qs->qconn, level, data, len);
   if(rv) {
     H3BUGF(fprintf(stderr, "write_client_handshake failed\n"));
   }
@@ -832,7 +814,6 @@ static int ng_getsock(struct Curl_easy *data, struct connectdata *conn,
 
 static void qs_disconnect(struct quicsocket *qs)
 {
-  int i;
   if(!qs->conn) /* already closed */
     return;
   qs->conn = NULL;
@@ -853,8 +834,6 @@ static void qs_disconnect(struct quicsocket *qs)
     qs->cred = NULL;
   }
 #endif
-  for(i = 0; i < 3; i++)
-    Curl_safefree(qs->crypto_data[i].buf);
   nghttp3_conn_del(qs->h3conn);
   ngtcp2_conn_del(qs->qconn);
 #ifdef USE_OPENSSL
index cbede451462f3562ec525d209f824f1a28dc672a..501453042b9b2caccba513ce2684c526b9dfbdaa 100644 (file)
 #include <gnutls/gnutls.h>
 #endif
 
-struct quic_handshake {
-  char *buf;       /* pointer to the buffer */
-  size_t alloclen; /* size of allocation */
-  size_t len;      /* size of content in buffer */
-  size_t nread;    /* how many bytes have been read */
-};
-
 struct quicsocket {
   struct connectdata *conn; /* point back to the connection */
   ngtcp2_conn *qconn;
@@ -56,7 +49,6 @@ struct quicsocket {
   gnutls_certificate_credentials_t cred;
   gnutls_session_t ssl;
 #endif
-  struct quic_handshake crypto_data[3];
   /* the last TLS alert description generated by the local endpoint */
   uint8_t tls_alert;
   struct sockaddr_storage local_addr;