#17 rebase to 8.0.1
Merged a year ago by kdudka. Opened a year ago by kdudka.
rpms/ kdudka/curl f38-rebase  into  f38

@@ -1,55 +0,0 @@ 

- From 613d3c45879636e88b88fcebee48dc77de345291 Mon Sep 17 00:00:00 2001

- From: Patrick Monnerat <patrick@monnerat.net>

- Date: Fri, 23 Dec 2022 15:35:27 +0100

- Subject: [PATCH] typecheck: accept expressions for option/info parameters

- 

- As expressions can have side effects, evaluate only once.

- 

- To enable deprecation reporting only once, get rid of the __typeof__

- use to define the local temporary variable and use the target type

- (CURLoption/CURLINFO). This also avoids multiple reports on type

- conflicts (if some) by the curlcheck_* macros.

- 

- Note that CURLOPT_* and CURLINFO_* symbols may be deprecated, but not

- their values: a curl_easy_setopt call with an integer constant as option

- will never report a deprecation.

- 

- Reported-by: Thomas Klausner

- Fixes #10148

- Closes #10149

- 

- Upstream-commit: e2aed004302e51cfa5b6ce8c8ab65ef92aa83196

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  include/curl/typecheck-gcc.h | 6 ++----

-  1 file changed, 2 insertions(+), 4 deletions(-)

- 

- diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h

- index bf655bb..85aa8b7 100644

- --- a/include/curl/typecheck-gcc.h

- +++ b/include/curl/typecheck-gcc.h

- @@ -42,9 +42,8 @@

-   */

-  #define curl_easy_setopt(handle, option, value)                         \

-    __extension__({                                                       \

- -      CURL_IGNORE_DEPRECATION(__typeof__(option) _curl_opt = option;)   \

- +      CURLoption _curl_opt = (option);                                  \

-        if(__builtin_constant_p(_curl_opt)) {                             \

- -        (void) option;                                                  \

-          CURL_IGNORE_DEPRECATION(                                        \

-            if(curlcheck_long_option(_curl_opt))                          \

-              if(!curlcheck_long(value))                                  \

- @@ -120,9 +119,8 @@

-  /* wraps curl_easy_getinfo() with typechecking */

-  #define curl_easy_getinfo(handle, info, arg)                            \

-    __extension__({                                                       \

- -      CURL_IGNORE_DEPRECATION(__typeof__(info) _curl_info = info;)      \

- +      CURLINFO _curl_info = (info);                                     \

-        if(__builtin_constant_p(_curl_info)) {                            \

- -        (void) info;                                                    \

-          CURL_IGNORE_DEPRECATION(                                        \

-            if(curlcheck_string_info(_curl_info))                         \

-              if(!curlcheck_arr((arg), char *))                           \

- -- 

- 2.39.0

- 

@@ -1,54 +0,0 @@ 

- From 34ba217b433f222f486a42f2157866ab40dba221 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Wed, 15 Feb 2023 15:04:07 +0100

- Subject: [PATCH] tests: make sure gnuserv-tls has SRP support before using it

- 

- Reported-by: fundawang on github

- Fixes #10522

- Closes #10524

- 

- Upstream-commit: 2fdc1d816ebf3c77f43068103bec1b3a3767881a

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  tests/runtests.pl |  2 +-

-  tests/sshhelp.pm  | 11 ++++++++++-

-  2 files changed, 11 insertions(+), 2 deletions(-)

- 

- diff --git a/tests/runtests.pl b/tests/runtests.pl

- index f49e385..d2e0e52 100755

- --- a/tests/runtests.pl

- +++ b/tests/runtests.pl

- @@ -5373,7 +5373,7 @@ sub startservers {

-          elsif($what eq "httptls") {

-              if(!$httptlssrv) {

-                  # for now, we can't run http TLS-EXT tests without gnutls-serv

- -                return "no gnutls-serv";

- +                return "no gnutls-serv (with SRP support)";

-              }

-              if($torture && $run{'httptls'} &&

-                 !responsive_httptls_server($verbose, "IPv4")) {

- diff --git a/tests/sshhelp.pm b/tests/sshhelp.pm

- index 2d419c1..0c553da 100644

- --- a/tests/sshhelp.pm

- +++ b/tests/sshhelp.pm

- @@ -408,7 +408,16 @@ sub find_sshkeygen {

-  # Find httptlssrv (gnutls-serv) and return canonical filename

-  #

-  sub find_httptlssrv {

- -    return find_exe_file_hpath($httptlssrvexe);

- +    my $p = find_exe_file_hpath($httptlssrvexe);

- +    my @o = `$p -l`;

- +    my $found;

- +    for(@o) {

- +        if(/Key exchange: SRP/) {

- +            $found = 1;

- +            last;

- +        }

- +    }

- +    return $p if($found);

-  }

-  

-  

- -- 

- 2.39.2

- 

@@ -1,40 +0,0 @@ 

- From 4388f4af77c6741873062dc8da5c6cbcef2d5dfd Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Mon, 26 Dec 2022 09:59:20 +0100

- Subject: [PATCH] cfilters:Curl_conn_get_select_socks: use the first

-  non-connected filter

- 

- When there are filters addded for both socket and SSL, the code

- previously checked the SSL sockets during connect when it *should* first

- check the socket layer until that has connected.

- 

- Fixes #10157

- Fixes #10146

- Closes #10160

- 

- Reviewed-by: Stefan Eissing

- 

- Upstream-commit: 728400f875e845f72ee5602edb905f6301ade3e7

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/cfilters.c | 4 ++++

-  1 file changed, 4 insertions(+)

- 

- diff --git a/lib/cfilters.c b/lib/cfilters.c

- index bcb33da..94471e8 100644

- --- a/lib/cfilters.c

- +++ b/lib/cfilters.c

- @@ -437,6 +437,10 @@ int Curl_conn_get_select_socks(struct Curl_easy *data, int sockindex,

-    DEBUGASSERT(data);

-    DEBUGASSERT(data->conn);

-    cf = data->conn->cfilter[sockindex];

- +

- +  /* if the next one is not yet connected, that's the one we want */

- +  while(cf && cf->next && !cf->next->connected)

- +    cf = cf->next;

-    if(cf) {

-      return cf->cft->get_select_socks(cf, data, socks);

-    }

- -- 

- 2.39.2

- 

@@ -1,575 +0,0 @@ 

- From 117fce3d4fe11c36a20403cd4d6850e5b8771b41 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Tue, 27 Dec 2022 11:50:20 +0100

- Subject: [PATCH 1/5] share: add sharing of HSTS cache among handles

- 

- Closes #10138

- 

- Upstream-commit: 076a2f629119222aeeb50f5a03bf9f9052fabb9a

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  docs/libcurl/opts/CURLSHOPT_SHARE.3 |  4 +++

-  docs/libcurl/symbols-in-versions    |  1 +

-  include/curl/curl.h                 |  1 +

-  lib/hsts.c                          | 15 +++++++++

-  lib/hsts.h                          |  2 ++

-  lib/setopt.c                        | 48 ++++++++++++++++++++++++-----

-  lib/share.c                         | 32 +++++++++++++++++--

-  lib/share.h                         |  6 +++-

-  lib/transfer.c                      |  3 ++

-  lib/url.c                           |  6 +++-

-  lib/urldata.h                       |  2 ++

-  11 files changed, 109 insertions(+), 11 deletions(-)

- 

- diff --git a/docs/libcurl/opts/CURLSHOPT_SHARE.3 b/docs/libcurl/opts/CURLSHOPT_SHARE.3

- index 92783b6..b15af82 100644

- --- a/docs/libcurl/opts/CURLSHOPT_SHARE.3

- +++ b/docs/libcurl/opts/CURLSHOPT_SHARE.3

- @@ -79,6 +79,10 @@ Added in 7.61.0.

-  

-  Note that when you use the multi interface, all easy handles added to the same

-  multi handle will share PSL cache by default without using this option.

- +.IP CURL_LOCK_DATA_HSTS

- +The in-memory HSTS cache.

- +

- +Added in 7.88.0

-  .SH PROTOCOLS

-  All

-  .SH EXAMPLE

- diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions

- index 5ee245d..41fffc3 100644

- --- a/docs/libcurl/symbols-in-versions

- +++ b/docs/libcurl/symbols-in-versions

- @@ -73,6 +73,7 @@ CURL_LOCK_ACCESS_SINGLE         7.10.3

-  CURL_LOCK_DATA_CONNECT          7.10.3

-  CURL_LOCK_DATA_COOKIE           7.10.3

-  CURL_LOCK_DATA_DNS              7.10.3

- +CURL_LOCK_DATA_HSTS             7.88.0

-  CURL_LOCK_DATA_NONE             7.10.3

-  CURL_LOCK_DATA_PSL              7.61.0

-  CURL_LOCK_DATA_SHARE            7.10.4

- diff --git a/include/curl/curl.h b/include/curl/curl.h

- index 139df99..5758e3b 100644

- --- a/include/curl/curl.h

- +++ b/include/curl/curl.h

- @@ -2953,6 +2953,7 @@ typedef enum {

-    CURL_LOCK_DATA_SSL_SESSION,

-    CURL_LOCK_DATA_CONNECT,

-    CURL_LOCK_DATA_PSL,

- +  CURL_LOCK_DATA_HSTS,

-    CURL_LOCK_DATA_LAST

-  } curl_lock_data;

-  

- diff --git a/lib/hsts.c b/lib/hsts.c

- index c449120..339237b 100644

- --- a/lib/hsts.c

- +++ b/lib/hsts.c

- @@ -39,6 +39,7 @@

-  #include "parsedate.h"

-  #include "fopen.h"

-  #include "rename.h"

- +#include "share.h"

-  

-  /* The last 3 #include files should be in this order */

-  #include "curl_printf.h"

- @@ -551,4 +552,18 @@ CURLcode Curl_hsts_loadcb(struct Curl_easy *data, struct hsts *h)

-    return CURLE_OK;

-  }

-  

- +void Curl_hsts_loadfiles(struct Curl_easy *data)

- +{

- +  struct curl_slist *l = data->set.hstslist;

- +  if(l) {

- +    Curl_share_lock(data, CURL_LOCK_DATA_HSTS, CURL_LOCK_ACCESS_SINGLE);

- +

- +    while(l) {

- +      (void)Curl_hsts_loadfile(data, data->hsts, l->data);

- +      l = l->next;

- +    }

- +    Curl_share_unlock(data, CURL_LOCK_DATA_HSTS);

- +  }

- +}

- +

-  #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */

- diff --git a/lib/hsts.h b/lib/hsts.h

- index 0e36a77..3da7574 100644

- --- a/lib/hsts.h

- +++ b/lib/hsts.h

- @@ -59,9 +59,11 @@ CURLcode Curl_hsts_loadfile(struct Curl_easy *data,

-                              struct hsts *h, const char *file);

-  CURLcode Curl_hsts_loadcb(struct Curl_easy *data,

-                            struct hsts *h);

- +void Curl_hsts_loadfiles(struct Curl_easy *data);

-  #else

-  #define Curl_hsts_cleanup(x)

-  #define Curl_hsts_loadcb(x,y) CURLE_OK

-  #define Curl_hsts_save(x,y,z)

- +#define Curl_hsts_loadfiles(x)

-  #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */

-  #endif /* HEADER_CURL_HSTS_H */

- diff --git a/lib/setopt.c b/lib/setopt.c

- index b77e95b..f71a606 100644

- --- a/lib/setopt.c

- +++ b/lib/setopt.c

- @@ -2260,9 +2260,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)

-          data->cookies = NULL;

-  #endif

-  

- +#ifndef CURL_DISABLE_HSTS

- +      if(data->share->hsts == data->hsts)

- +        data->hsts = NULL;

- +#endif

- +#ifdef USE_SSL

-        if(data->share->sslsession == data->state.session)

-          data->state.session = NULL;

- -

- +#endif

-  #ifdef USE_LIBPSL

-        if(data->psl == &data->share->psl)

-          data->psl = data->multi? &data->multi->psl: NULL;

- @@ -2296,10 +2301,19 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)

-          data->cookies = data->share->cookies;

-        }

-  #endif   /* CURL_DISABLE_HTTP */

- +#ifndef CURL_DISABLE_HSTS

- +      if(data->share->hsts) {

- +        /* first free the private one if any */

- +        Curl_hsts_cleanup(&data->hsts);

- +        data->hsts = data->share->hsts;

- +      }

- +#endif   /* CURL_DISABLE_HTTP */

- +#ifdef USE_SSL

-        if(data->share->sslsession) {

-          data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;

-          data->state.session = data->share->sslsession;

-        }

- +#endif

-  #ifdef USE_LIBPSL

-        if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))

-          data->psl = &data->share->psl;

- @@ -3049,19 +3063,39 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)

-    case CURLOPT_HSTSWRITEDATA:

-      data->set.hsts_write_userp = va_arg(param, void *);

-      break;

- -  case CURLOPT_HSTS:

- +  case CURLOPT_HSTS: {

- +    struct curl_slist *h;

-      if(!data->hsts) {

-        data->hsts = Curl_hsts_init();

-        if(!data->hsts)

-          return CURLE_OUT_OF_MEMORY;

-      }

-      argptr = va_arg(param, char *);

- -    result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr);

- -    if(result)

- -      return result;

- -    if(argptr)

- -      (void)Curl_hsts_loadfile(data, data->hsts, argptr);

- +    if(argptr) {

- +      result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr);

- +      if(result)

- +        return result;

- +      /* this needs to build a list of file names to read from, so that it can

- +         read them later, as we might get a shared HSTS handle to load them

- +         into */

- +      h = curl_slist_append(data->set.hstslist, argptr);

- +      if(!h) {

- +        curl_slist_free_all(data->set.hstslist);

- +        data->set.hstslist = NULL;

- +        return CURLE_OUT_OF_MEMORY;

- +      }

- +      data->set.hstslist = h; /* store the list for later use */

- +    }

- +    else {

- +      /* clear the list of HSTS files */

- +      curl_slist_free_all(data->set.hstslist);

- +      data->set.hstslist = NULL;

- +      if(!data->share || !data->share->hsts)

- +        /* throw away the HSTS cache unless shared */

- +        Curl_hsts_cleanup(&data->hsts);

- +    }

-      break;

- +  }

-    case CURLOPT_HSTS_CTRL:

-      arg = va_arg(param, long);

-      if(arg & CURLHSTS_ENABLE) {

- diff --git a/lib/share.c b/lib/share.c

- index 1a083e7..69ee00b 100644

- --- a/lib/share.c

- +++ b/lib/share.c

- @@ -29,9 +29,11 @@

-  #include "share.h"

-  #include "psl.h"

-  #include "vtls/vtls.h"

- -#include "curl_memory.h"

- +#include "hsts.h"

-  

- -/* The last #include file should be: */

- +/* The last 3 #include files should be in this order */

- +#include "curl_printf.h"

- +#include "curl_memory.h"

-  #include "memdebug.h"

-  

-  struct Curl_share *

- @@ -89,6 +91,18 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)

-  #endif

-        break;

-  

- +    case CURL_LOCK_DATA_HSTS:

- +#ifndef CURL_DISABLE_HSTS

- +      if(!share->hsts) {

- +        share->hsts = Curl_hsts_init();

- +        if(!share->hsts)

- +          res = CURLSHE_NOMEM;

- +      }

- +#else   /* CURL_DISABLE_HSTS */

- +      res = CURLSHE_NOT_BUILT_IN;

- +#endif

- +      break;

- +

-      case CURL_LOCK_DATA_SSL_SESSION:

-  #ifdef USE_SSL

-        if(!share->sslsession) {

- @@ -141,6 +155,16 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)

-  #endif

-        break;

-  

- +    case CURL_LOCK_DATA_HSTS:

- +#ifndef CURL_DISABLE_HSTS

- +      if(share->hsts) {

- +        Curl_hsts_cleanup(&share->hsts);

- +      }

- +#else   /* CURL_DISABLE_HSTS */

- +      res = CURLSHE_NOT_BUILT_IN;

- +#endif

- +      break;

- +

-      case CURL_LOCK_DATA_SSL_SESSION:

-  #ifdef USE_SSL

-        Curl_safefree(share->sslsession);

- @@ -207,6 +231,10 @@ curl_share_cleanup(struct Curl_share *share)

-    Curl_cookie_cleanup(share->cookies);

-  #endif

-  

- +#ifndef CURL_DISABLE_HSTS

- +  Curl_hsts_cleanup(&share->hsts);

- +#endif

- +

-  #ifdef USE_SSL

-    if(share->sslsession) {

-      size_t i;

- diff --git a/lib/share.h b/lib/share.h

- index 32be416..2449730 100644

- --- a/lib/share.h

- +++ b/lib/share.h

- @@ -59,10 +59,14 @@ struct Curl_share {

-  #ifdef USE_LIBPSL

-    struct PslCache psl;

-  #endif

- -

- +#ifndef CURL_DISABLE_HSTS

- +  struct hsts *hsts;

- +#endif

- +#ifdef USE_SSL

-    struct Curl_ssl_session *sslsession;

-    size_t max_ssl_sessions;

-    long sessionage;

- +#endif

-  };

-  

-  CURLSHcode Curl_share_lock(struct Curl_easy *, curl_lock_data,

- diff --git a/lib/transfer.c b/lib/transfer.c

- index ba0410f..d433117 100644

- --- a/lib/transfer.c

- +++ b/lib/transfer.c

- @@ -1398,6 +1398,9 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)

-    if(data->state.resolve)

-      result = Curl_loadhostpairs(data);

-  

- +  /* If there is a list of hsts files to read */

- +  Curl_hsts_loadfiles(data);

- +

-    if(!result) {

-      /* Allow data->set.use_port to set which port to use. This needs to be

-       * disabled for example when we follow Location: headers to URLs using

- diff --git a/lib/url.c b/lib/url.c

- index 3ab63a0..831ae06 100644

- --- a/lib/url.c

- +++ b/lib/url.c

- @@ -434,7 +434,11 @@ CURLcode Curl_close(struct Curl_easy **datap)

-    Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]);

-    Curl_altsvc_cleanup(&data->asi);

-    Curl_hsts_save(data, data->hsts, data->set.str[STRING_HSTS]);

- -  Curl_hsts_cleanup(&data->hsts);

- +#ifndef CURL_DISABLE_HSTS

- +  if(!data->share || !data->share->hsts)

- +    Curl_hsts_cleanup(&data->hsts);

- +  curl_slist_free_all(data->set.hstslist); /* clean up list */

- +#endif

-  #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)

-    Curl_http_auth_cleanup_digest(data);

-  #endif

- diff --git a/lib/urldata.h b/lib/urldata.h

- index 3d7545c..5b4b34f 100644

- --- a/lib/urldata.h

- +++ b/lib/urldata.h

- @@ -1662,6 +1662,8 @@ struct UserDefined {

-  

-    void *seek_client;    /* pointer to pass to the seek callback */

-  #ifndef CURL_DISABLE_HSTS

- +  struct curl_slist *hstslist; /* list of HSTS files set by

- +                                  curl_easy_setopt(HSTS) calls */

-    curl_hstsread_callback hsts_read;

-    void *hsts_read_userp;

-    curl_hstswrite_callback hsts_write;

- -- 

- 2.39.1

- 

- 

- From 32066a5fa8f649da2aa7a4e4e86bc0b73d32212f Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Tue, 27 Dec 2022 11:50:23 +0100

- Subject: [PATCH 2/5] tool_operate: share HSTS between handles

- 

- Upstream-commit: 0bf8b796a0ea98395b390c7807187982215f5c11

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  src/tool_operate.c | 1 +

-  1 file changed, 1 insertion(+)

- 

- diff --git a/src/tool_operate.c b/src/tool_operate.c

- index 79db063..a5b024e 100644

- --- a/src/tool_operate.c

- +++ b/src/tool_operate.c

- @@ -2722,6 +2722,7 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])

-          curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);

-          curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);

-          curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);

- +        curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);

-  

-          /* Get the required arguments for each operation */

-          do {

- -- 

- 2.39.1

- 

- 

- From fe6b64ac33a0994e5f50ef8b3d0916b3a248a7e8 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Tue, 27 Dec 2022 11:50:23 +0100

- Subject: [PATCH 3/5] hsts: handle adding the same host name again

- 

- It will then use the largest expire time of the two entries.

- 

- Upstream-commit: ca02a77f05bd5cef20618c8f741aa48b7be0a648

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/hsts.c | 13 +++++++++++--

-  1 file changed, 11 insertions(+), 2 deletions(-)

- 

- diff --git a/lib/hsts.c b/lib/hsts.c

- index 339237b..8d6723e 100644

- --- a/lib/hsts.c

- +++ b/lib/hsts.c

- @@ -426,14 +426,23 @@ static CURLcode hsts_add(struct hsts *h, char *line)

-    if(2 == rc) {

-      time_t expires = strcmp(date, UNLIMITED) ? Curl_getdate_capped(date) :

-        TIME_T_MAX;

- -    CURLcode result;

- +    CURLcode result = CURLE_OK;

-      char *p = host;

-      bool subdomain = FALSE;

- +    struct stsentry *e;

-      if(p[0] == '.') {

-        p++;

-        subdomain = TRUE;

-      }

- -    result = hsts_create(h, p, subdomain, expires);

- +    /* only add it if not already present */

- +    e = Curl_hsts(h, p, subdomain);

- +    if(!e)

- +      result = hsts_create(h, p, subdomain, expires);

- +    else {

- +      /* the same host name, use the largest expire time */

- +      if(expires > e->expires)

- +        e->expires = expires;

- +    }

-      if(result)

-        return result;

-    }

- -- 

- 2.39.1

- 

- 

- From c52b93434c65ec8a44193a6f2b833a1efec8f643 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Tue, 27 Dec 2022 11:50:23 +0100

- Subject: [PATCH 4/5] runtests: support crlf="yes" for verify/proxy

- 

- Upstream-commit: dc0725244a3163f1e2d5f51165db3a1a430f3ba0

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  tests/FILEFORMAT.md | 4 ++--

-  tests/runtests.pl   | 5 +++++

-  2 files changed, 7 insertions(+), 2 deletions(-)

- 

- diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md

- index 8143967..be11167 100644

- --- a/tests/FILEFORMAT.md

- +++ b/tests/FILEFORMAT.md

- @@ -566,7 +566,7 @@ changing protocol data such as port numbers or user-agent strings.

-  One perl op per line that operates on the protocol dump. This is pretty

-  advanced. Example: `s/^EPRT .*/EPRT stripped/`.

-  

- -### `<protocol [nonewline="yes"] crlf="yes">`

- +### `<protocol [nonewline="yes"][crlf="yes"]>`

-  

-  the protocol dump curl should transmit, if `nonewline` is set, we will cut off

-  the trailing newline of this given data before comparing with the one actually

- @@ -576,7 +576,7 @@ comparisons are made.

-  `crlf=yes` forces the newlines to become CRLF even if not written so in the

-  test.

-  

- -### `<proxy [nonewline="yes"]>`

- +### `<proxy [nonewline="yes"][crlf="yes"]>`

-  

-  The protocol dump curl should transmit to an HTTP proxy (when the http-proxy

-  server is used), if `nonewline` is set, we will cut off the trailing newline

- diff --git a/tests/runtests.pl b/tests/runtests.pl

- index c6a739e..f49e385 100755

- --- a/tests/runtests.pl

- +++ b/tests/runtests.pl

- @@ -4744,6 +4744,11 @@ sub singletest {

-              }

-          }

-  

- +        if($hash{'crlf'} ||

- +           ($has_hyper && ($keywords{"HTTP"} || $keywords{"HTTPS"}))) {

- +            map subNewlines(0, \$_), @protstrip;

- +        }

- +

-          $res = compare($testnum, $testname, "proxy", \@out, \@protstrip);

-          if($res) {

-              return $errorreturncode;

- -- 

- 2.39.1

- 

- 

- From e428f66157caedc1f58ff5206915842937b0950e Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Tue, 27 Dec 2022 11:50:23 +0100

- Subject: [PATCH 5/5] test446: verify hsts with two URLs

- 

- Upstream-commit: ea5aaaa5ede53819f8bc7ae767fc2d13d3704d37

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  tests/data/Makefile.inc |  2 +-

-  tests/data/test446      | 84 +++++++++++++++++++++++++++++++++++++++++

-  2 files changed, 85 insertions(+), 1 deletion(-)

-  create mode 100644 tests/data/test446

- 

- diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc

- index 3e0221a..fb51cd6 100644

- --- a/tests/data/Makefile.inc

- +++ b/tests/data/Makefile.inc

- @@ -71,7 +71,7 @@ test408 test409 test410 test411 test412 test413 test414 test415 test416 \

-  \

-  test430 test431 test432 test433 test434 test435 test436 \

-  \

- -test440 test441 test442 test443 test444 test445 \

- +test440 test441 test442 test443 test444 test445 test446 \

-  \

-  test490 test491 test492 test493 test494 test495 test496 \

-  \

- diff --git a/tests/data/test446 b/tests/data/test446

- new file mode 100644

- index 0000000..0e2dfdc

- --- /dev/null

- +++ b/tests/data/test446

- @@ -0,0 +1,84 @@

- +<?xml version="1.0" encoding="ISO-8859-1"?>

- +<testcase>

- +<info>

- +<keywords>

- +HTTP

- +HTTP proxy

- +HSTS

- +trailing-dot

- +</keywords>

- +</info>

- +

- +<reply>

- +

- +# we use this as response to a CONNECT

- +<connect nocheck="yes">

- +HTTP/1.1 200 OK

- +

- +</connect>

- +<data crlf="yes">

- +HTTP/1.1 200 OK

- +Content-Length: 6

- +Strict-Transport-Security: max-age=604800

- +

- +-foo-

- +</data>

- +<data2 crlf="yes">

- +HTTP/1.1 200 OK

- +Content-Length: 6

- +Strict-Transport-Security: max-age=6048000

- +

- +-baa-

- +</data2>

- +</reply>

- +

- +<client>

- +<server>

- +https

- +http-proxy

- +</server>

- +<features>

- +HSTS

- +proxy

- +https

- +debug

- +</features>

- +<setenv>

- +CURL_HSTS_HTTP=yes

- +CURL_TIME=2000000000

- +</setenv>

- +

- +<name>

- +HSTS with two URLs

- +</name>

- +<command>

- +-x http://%HOSTIP:%PROXYPORT --hsts log/hsts%TESTNUMBER http://this.hsts.example./%TESTNUMBER http://another.example.com/%TESTNUMBER0002

- +</command>

- +</client>

- +

- +<verify>

- +# we let it CONNECT to the server to confirm HSTS but deny from there

- +<proxy crlf="yes">

- +GET http://this.hsts.example./%TESTNUMBER HTTP/1.1

- +Host: this.hsts.example.

- +User-Agent: curl/%VERSION

- +Accept: */*

- +Proxy-Connection: Keep-Alive

- +

- +GET http://another.example.com/%TESTNUMBER0002 HTTP/1.1

- +Host: another.example.com

- +User-Agent: curl/%VERSION

- +Accept: */*

- +Proxy-Connection: Keep-Alive

- +

- +</proxy>

- +

- +<file name="log/hsts%TESTNUMBER" mode="text">

- +# Your HSTS cache. https://curl.se/docs/hsts.html

- +# This file was generated by libcurl! Edit at your own risk.

- +this.hsts.example "20330525 03:33:20"

- +another.example.com "20330727 03:33:20"

- +</file>

- +

- +</verify>

- +</testcase>

- -- 

- 2.39.1

- 

@@ -1,243 +0,0 @@ 

- From bc5fc958b017895728962c9d44c469418cbec1a0 Mon Sep 17 00:00:00 2001

- From: Patrick Monnerat <patrick@monnerat.net>

- Date: Mon, 13 Feb 2023 08:33:09 +0100

- Subject: [PATCH] content_encoding: do not reset stage counter for each header

- 

- Test 418 verifies

- 

- Closes #10492

- 

- Upstream-commit: 119fb187192a9ea13dc90d9d20c215fc82799ab9

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/content_encoding.c  |   7 +-

-  lib/urldata.h           |   1 +

-  tests/data/Makefile.inc |   1 +

-  tests/data/test387      |   2 +-

-  tests/data/test418      | 152 ++++++++++++++++++++++++++++++++++++++++

-  5 files changed, 158 insertions(+), 5 deletions(-)

-  create mode 100644 tests/data/test418

- 

- diff --git a/lib/content_encoding.c b/lib/content_encoding.c

- index bfc13e2..94344d6 100644

- --- a/lib/content_encoding.c

- +++ b/lib/content_encoding.c

- @@ -1045,7 +1045,6 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,

-                                       const char *enclist, int maybechunked)

-  {

-    struct SingleRequest *k = &data->req;

- -  int counter = 0;

-  

-    do {

-      const char *name;

- @@ -1080,9 +1079,9 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,

-        if(!encoding)

-          encoding = &error_encoding;  /* Defer error at stack use. */

-  

- -      if(++counter >= MAX_ENCODE_STACK) {

- -        failf(data, "Reject response due to %u content encodings",

- -              counter);

- +      if(k->writer_stack_depth++ >= MAX_ENCODE_STACK) {

- +        failf(data, "Reject response due to more than %u content encodings",

- +              MAX_ENCODE_STACK);

-          return CURLE_BAD_CONTENT_ENCODING;

-        }

-        /* Stack the unencoding stage. */

- diff --git a/lib/urldata.h b/lib/urldata.h

- index 5b4b34f..8c8c20b 100644

- --- a/lib/urldata.h

- +++ b/lib/urldata.h

- @@ -707,6 +707,7 @@ struct SingleRequest {

-    struct dohdata *doh; /* DoH specific data for this request */

-  #endif

-    unsigned char setcookies;

- +  unsigned char writer_stack_depth; /* Unencoding stack depth. */

-    BIT(header);        /* incoming data has HTTP header */

-    BIT(content_range); /* set TRUE if Content-Range: was found */

-    BIT(upload_done);   /* set to TRUE when doing chunked transfer-encoding

- diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc

- index fb51cd6..86b6f85 100644

- --- a/tests/data/Makefile.inc

- +++ b/tests/data/Makefile.inc

- @@ -68,6 +68,7 @@ test380 test381 test383 test384 test385 test386 test387 test388 test389 \

-  test390 test391 test392 test393 test394 test395 test396 test397 test398 \

-  test399 test400 test401 test402 test403 test404 test405 test406 test407 \

-  test408 test409 test410 test411 test412 test413 test414 test415 test416 \

- +        test418 \

-  \

-  test430 test431 test432 test433 test434 test435 test436 \

-  \

- diff --git a/tests/data/test387 b/tests/data/test387

- index 015ec25..644fc7f 100644

- --- a/tests/data/test387

- +++ b/tests/data/test387

- @@ -47,7 +47,7 @@ Accept: */*

-  61

-  </errorcode>

-  <stderr mode="text">

- -curl: (61) Reject response due to 5 content encodings

- +curl: (61) Reject response due to more than 5 content encodings

-  </stderr>

-  </verify>

-  </testcase>

- diff --git a/tests/data/test418 b/tests/data/test418

- new file mode 100644

- index 0000000..50e974e

- --- /dev/null

- +++ b/tests/data/test418

- @@ -0,0 +1,152 @@

- +<testcase>

- +<info>

- +<keywords>

- +HTTP

- +gzip

- +</keywords>

- +</info>

- +

- +#

- +# Server-side

- +<reply>

- +<data nocheck="yes">

- +HTTP/1.1 200 OK

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +Transfer-Encoding: gzip

- +

- +-foo-

- +</data>

- +</reply>

- +

- +#

- +# Client-side

- +<client>

- +<server>

- +http

- +</server>

- + <name>

- +Response with multiple Transfer-Encoding headers

- + </name>

- + <command>

- +http://%HOSTIP:%HTTPPORT/%TESTNUMBER -sS

- +</command>

- +</client>

- +

- +#

- +# Verify data after the test has been "shot"

- +<verify>

- +<protocol crlf="yes">

- +GET /%TESTNUMBER HTTP/1.1

- +Host: %HOSTIP:%HTTPPORT

- +User-Agent: curl/%VERSION

- +Accept: */*

- +

- +</protocol>

- +

- +# CURLE_BAD_CONTENT_ENCODING is 61

- +<errorcode>

- +61

- +</errorcode>

- +<stderr mode="text">

- +curl: (61) Reject response due to more than 5 content encodings

- +</stderr>

- +</verify>

- +</testcase>

- -- 

- 2.39.1

- 

@@ -1,177 +0,0 @@ 

- From d12c233950e22052a8541abd69565772c13f832e Mon Sep 17 00:00:00 2001

- From: Stefan Eissing <stefan@eissing.org>

- Date: Tue, 17 Jan 2023 11:21:29 +0100

- Subject: [PATCH] vtls: fix hostname handling in filters

- 

- - Copy the hostname and dispname to ssl_connect_data.

- 

- Use a copy instead of referencing the `connectdata` instance since this

- may get free'ed on connection reuse.

- 

- Reported-by: Stefan Talpalaru

- Reported-by: sergio-nsk@users.noreply.github.com

- 

- Fixes https://github.com/curl/curl/issues/10273

- Fixes https://github.com/curl/curl/issues/10309

- 

- Closes https://github.com/curl/curl/pull/10310

- 

- Upstream-commit: f8da4f2f2d0451dc0a126ae3e5077b4527ccdc86

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/url.c           | 14 ++++++++++

-  lib/vtls/vtls.c     | 66 ++++++++++++++++++++++++++++++---------------

-  lib/vtls/vtls_int.h |  4 +--

-  3 files changed, 61 insertions(+), 23 deletions(-)

- 

- diff --git a/lib/url.c b/lib/url.c

- index cbbc7f3..5192204 100644

- --- a/lib/url.c

- +++ b/lib/url.c

- @@ -3406,6 +3406,20 @@ static void reuse_conn(struct Curl_easy *data,

-    }

-  #endif

-  

- +  /* Finding a connection for reuse in the cache matches, among other

- +   * things on the "remote-relevant" hostname. This is not necessarily

- +   * the authority of the URL, e.g. conn->host. For example:

- +   * - we use a proxy (not tunneling). we want to send all requests

- +   *   that use the same proxy on this connection.

- +   * - we have a "connect-to" setting that may redirect the hostname of

- +   *   a new request to the same remote endpoint of an existing conn.

- +   *   We want to reuse an existing conn to the remote endpoint.

- +   * Since connection reuse does not match on conn->host necessarily, we

- +   * switch `existing` conn to `temp` conn's host settings.

- +   * TODO: is this correct in the case of TLS connections that have

- +   *       used the original hostname in SNI to negotiate? Do we send

- +   *       requests for another host through the different SNI?

- +   */

-    Curl_free_idnconverted_hostname(&existing->host);

-    Curl_free_idnconverted_hostname(&existing->conn_to_host);

-    Curl_safefree(existing->host.rawalloc);

- diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c

- index 873ee6b..c7ec77a 100644

- --- a/lib/vtls/vtls.c

- +++ b/lib/vtls/vtls.c

- @@ -1430,47 +1430,71 @@ CURLsslset Curl_init_sslset_nolock(curl_sslbackend id, const char *name,

-  

-  #ifdef USE_SSL

-  

- +static void free_hostname(struct ssl_connect_data *connssl)

- +{

- +  if(connssl->dispname != connssl->hostname)

- +    free(connssl->dispname);

- +  free(connssl->hostname);

- +  connssl->hostname = connssl->dispname = NULL;

- +}

- +

-  static void cf_close(struct Curl_cfilter *cf, struct Curl_easy *data)

-  {

-    struct ssl_connect_data *connssl = cf->ctx;

- -  /* TODO: close_one closes BOTH conn->ssl AND conn->proxy_ssl for this

- -   * sockindex (if in use). Gladly, it is safe to call more than once. */

-    if(connssl) {

-      Curl_ssl->close(cf, data);

-      connssl->state = ssl_connection_none;

- +    free_hostname(connssl);

-    }

-    cf->connected = FALSE;

-  }

-  

- -static void reinit_hostname(struct Curl_cfilter *cf)

- +static CURLcode reinit_hostname(struct Curl_cfilter *cf)

-  {

-    struct ssl_connect_data *connssl = cf->ctx;

- +  const char *ehostname, *edispname;

- +  int eport;

-  

- +  /* We need the hostname for SNI negotiation. Once handshaked, this

- +   * remains the SNI hostname for the TLS connection. But when the

- +   * connection is reused, the settings in cf->conn might change.

- +   * So we keep a copy of the hostname we use for SNI.

- +   */

-  #ifndef CURL_DISABLE_PROXY

-    if(Curl_ssl_cf_is_proxy(cf)) {

- -    /* TODO: there is not definition for a proxy setup on a secondary conn */

- -    connssl->hostname = cf->conn->http_proxy.host.name;

- -    connssl->dispname = cf->conn->http_proxy.host.dispname;

- -    connssl->port = cf->conn->http_proxy.port;

- +    ehostname = cf->conn->http_proxy.host.name;

- +    edispname = cf->conn->http_proxy.host.dispname;

- +    eport = cf->conn->http_proxy.port;

-    }

-    else

-  #endif

-    {

- -    /* TODO: secondaryhostname is set to the IP address we connect to

- -     * in the FTP handler, it is assumed that host verification uses the

- -     * hostname from FIRSTSOCKET */

- -    if(cf->sockindex == SECONDARYSOCKET && 0) {

- -      connssl->hostname = cf->conn->secondaryhostname;

- -      connssl->dispname = connssl->hostname;

- -      connssl->port = cf->conn->secondary_port;

- +    ehostname = cf->conn->host.name;

- +    edispname = cf->conn->host.dispname;

- +    eport = cf->conn->remote_port;

- +  }

- +

- +  /* change if ehostname changed */

- +  if(ehostname && (!connssl->hostname

- +                   || strcmp(ehostname, connssl->hostname))) {

- +    free_hostname(connssl);

- +    connssl->hostname = strdup(ehostname);

- +    if(!connssl->hostname) {

- +      free_hostname(connssl);

- +      return CURLE_OUT_OF_MEMORY;

-      }

- +    if(!edispname || !strcmp(ehostname, edispname))

- +      connssl->dispname = connssl->hostname;

-      else {

- -      connssl->hostname = cf->conn->host.name;

- -      connssl->dispname = cf->conn->host.dispname;

- -      connssl->port = cf->conn->remote_port;

- +      connssl->dispname = strdup(edispname);

- +      if(!connssl->dispname) {

- +        free_hostname(connssl);

- +        return CURLE_OUT_OF_MEMORY;

- +      }

-      }

-    }

- -  DEBUGASSERT(connssl->hostname);

- +  connssl->port = eport;

- +  return CURLE_OK;

-  }

-  

-  static void ssl_cf_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)

- @@ -1513,10 +1537,10 @@ static CURLcode ssl_cf_connect(struct Curl_cfilter *cf,

-    if(result || !*done)

-      goto out;

-  

- -  /* TODO: right now we do not fully control when hostname is set,

- -   * assign it on each connect call. */

- -  reinit_hostname(cf);

-    *done = FALSE;

- +  result = reinit_hostname(cf);

- +  if(result)

- +    goto out;

-  

-    if(blocking) {

-      result = ssl_connect(cf, data);

- diff --git a/lib/vtls/vtls_int.h b/lib/vtls/vtls_int.h

- index 6710a2b..010c20b 100644

- --- a/lib/vtls/vtls_int.h

- +++ b/lib/vtls/vtls_int.h

- @@ -33,8 +33,8 @@

-  struct ssl_connect_data {

-    ssl_connection_state state;

-    ssl_connect_state connecting_state;

- -  const char *hostname;             /* hostnaem for verification */

- -  const char *dispname;             /* display version of hostname */

- +  char *hostname;                   /* hostname for verification */

- +  char *dispname;                   /* display version of hostname */

-    int port;                         /* remote port at origin */

-    struct ssl_backend_data *backend; /* vtls backend specific props */

-    struct Curl_easy *call_data;      /* data handle used in current call,

- -- 

- 2.40.1

- 

@@ -1,263 +0,0 @@ 

- From bc893dea666ffa09fa015f0a585eb62a489749fc Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Thu, 5 Jan 2023 09:38:11 +0100

- Subject: [PATCH] http_proxy: do not assign data->req.p.http use local copy

- 

- Avoid the tricky reusing of the data->req.p.http pointer for http proxy

- tunneling.

- 

- Fixes #10194

- Closes #10234

- 

- Upstream-commit: 3f3ddee0665176040b3eaf89a912a922726ecb18

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/http.c       | 32 ++++++++++++++++++--------------

-  lib/http.h       |  3 +++

-  lib/http_proxy.c | 25 +++++++------------------

-  lib/rtsp.c       |  2 +-

-  4 files changed, 29 insertions(+), 33 deletions(-)

- 

- diff --git a/lib/http.c b/lib/http.c

- index 1b75022..4cf6043 100644

- --- a/lib/http.c

- +++ b/lib/http.c

- @@ -1256,8 +1256,8 @@ static size_t readmoredata(char *buffer,

-                             size_t nitems,

-                             void *userp)

-  {

- -  struct Curl_easy *data = (struct Curl_easy *)userp;

- -  struct HTTP *http = data->req.p.http;

- +  struct HTTP *http = (struct HTTP *)userp;

- +  struct Curl_easy *data = http->backup.data;

-    size_t fullsize = size * nitems;

-  

-    if(!http->postsize)

- @@ -1309,6 +1309,7 @@ static size_t readmoredata(char *buffer,

-   */

-  CURLcode Curl_buffer_send(struct dynbuf *in,

-                            struct Curl_easy *data,

- +                          struct HTTP *http,

-                            /* add the number of sent bytes to this

-                               counter */

-                            curl_off_t *bytes_written,

- @@ -1321,7 +1322,6 @@ CURLcode Curl_buffer_send(struct dynbuf *in,

-    char *ptr;

-    size_t size;

-    struct connectdata *conn = data->conn;

- -  struct HTTP *http = data->req.p.http;

-    size_t sendsize;

-    curl_socket_t sockfd;

-    size_t headersize;

- @@ -1456,10 +1456,11 @@ CURLcode Curl_buffer_send(struct dynbuf *in,

-          http->backup.fread_in = data->state.in;

-          http->backup.postdata = http->postdata;

-          http->backup.postsize = http->postsize;

- +        http->backup.data = data;

-  

-          /* set the new pointers for the request-sending */

-          data->state.fread_func = (curl_read_callback)readmoredata;

- -        data->state.in = (void *)data;

- +        data->state.in = (void *)http;

-          http->postdata = ptr;

-          http->postsize = (curl_off_t)size;

-  

- @@ -1468,7 +1469,6 @@ CURLcode Curl_buffer_send(struct dynbuf *in,

-  

-          http->send_buffer = *in; /* copy the whole struct */

-          http->sending = HTTPSEND_REQUEST;

- -

-          return CURLE_OK;

-        }

-        http->sending = HTTPSEND_BODY;

- @@ -2359,7 +2359,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-    curl_off_t included_body = 0;

-  #else

-    /* from this point down, this function should not be used */

- -#define Curl_buffer_send(a,b,c,d,e) CURLE_OK

- +#define Curl_buffer_send(a,b,c,d,e,f) CURLE_OK

-  #endif

-    CURLcode result = CURLE_OK;

-    struct HTTP *http = data->req.p.http;

- @@ -2403,7 +2403,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-      Curl_pgrsSetUploadSize(data, http->postsize);

-  

-      /* this sends the buffer and frees all the buffer resources */

- -    result = Curl_buffer_send(r, data, &data->info.request_size, 0,

- +    result = Curl_buffer_send(r, data, data->req.p.http,

- +                              &data->info.request_size, 0,

-                                FIRSTSOCKET);

-      if(result)

-        failf(data, "Failed sending PUT request");

- @@ -2424,7 +2425,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-        if(result)

-          return result;

-  

- -      result = Curl_buffer_send(r, data, &data->info.request_size, 0,

- +      result = Curl_buffer_send(r, data, data->req.p.http,

- +                                &data->info.request_size, 0,

-                                  FIRSTSOCKET);

-        if(result)

-          failf(data, "Failed sending POST request");

- @@ -2495,7 +2497,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-      http->sending = HTTPSEND_BODY;

-  

-      /* this sends the buffer and frees all the buffer resources */

- -    result = Curl_buffer_send(r, data, &data->info.request_size, 0,

- +    result = Curl_buffer_send(r, data, data->req.p.http,

- +                              &data->info.request_size, 0,

-                                FIRSTSOCKET);

-      if(result)

-        failf(data, "Failed sending POST request");

- @@ -2612,11 +2615,10 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-        else {

-          /* A huge POST coming up, do data separate from the request */

-          http->postdata = data->set.postfields;

- -

-          http->sending = HTTPSEND_BODY;

- -

- +        http->backup.data = data;

-          data->state.fread_func = (curl_read_callback)readmoredata;

- -        data->state.in = (void *)data;

- +        data->state.in = (void *)http;

-  

-          /* set the upload size to the progress meter */

-          Curl_pgrsSetUploadSize(data, http->postsize);

- @@ -2655,7 +2657,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-        }

-      }

-      /* issue the request */

- -    result = Curl_buffer_send(r, data, &data->info.request_size, included_body,

- +    result = Curl_buffer_send(r, data, data->req.p.http,

- +                              &data->info.request_size, included_body,

-                                FIRSTSOCKET);

-  

-      if(result)

- @@ -2671,7 +2674,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,

-        return result;

-  

-      /* issue the request */

- -    result = Curl_buffer_send(r, data, &data->info.request_size, 0,

- +    result = Curl_buffer_send(r, data, data->req.p.http,

- +                              &data->info.request_size, 0,

-                                FIRSTSOCKET);

-      if(result)

-        failf(data, "Failed sending HTTP request");

- diff --git a/lib/http.h b/lib/http.h

- index ecfe4ee..bd2b5f6 100644

- --- a/lib/http.h

- +++ b/lib/http.h

- @@ -73,8 +73,10 @@ char *Curl_checkProxyheaders(struct Curl_easy *data,

-                               const struct connectdata *conn,

-                               const char *thisheader,

-                               const size_t thislen);

- +struct HTTP; /* see below */

-  CURLcode Curl_buffer_send(struct dynbuf *in,

-                            struct Curl_easy *data,

- +                          struct HTTP *http,

-                            curl_off_t *bytes_written,

-                            curl_off_t included_body_bytes,

-                            int socketindex);

- @@ -220,6 +222,7 @@ struct HTTP {

-      void *fread_in;           /* backup storage for fread_in pointer */

-      const char *postdata;

-      curl_off_t postsize;

- +    struct Curl_easy *data;

-    } backup;

-  

-    enum {

- diff --git a/lib/http_proxy.c b/lib/http_proxy.c

- index e30730a..14f11e9 100644

- --- a/lib/http_proxy.c

- +++ b/lib/http_proxy.c

- @@ -63,8 +63,7 @@ struct tunnel_state {

-    int sockindex;

-    const char *hostname;

-    int remote_port;

- -  struct HTTP http_proxy;

- -  struct HTTP *prot_save;

- +  struct HTTP CONNECT;

-    struct dynbuf rcvbuf;

-    struct dynbuf req;

-    size_t nsend;

- @@ -149,17 +148,6 @@ static CURLcode tunnel_init(struct tunnel_state **pts,

-    Curl_dyn_init(&ts->rcvbuf, DYN_PROXY_CONNECT_HEADERS);

-    Curl_dyn_init(&ts->req, DYN_HTTP_REQUEST);

-  

- -  /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the

- -   * member conn->proto.http; we want [protocol] through HTTP and we have

- -   * to change the member temporarily for connecting to the HTTP

- -   * proxy. After Curl_proxyCONNECT we have to set back the member to the

- -   * original pointer

- -   *

- -   * This function might be called several times in the multi interface case

- -   * if the proxy's CONNECT response is not instant.

- -   */

- -  ts->prot_save = data->req.p.http;

- -  data->req.p.http = &ts->http_proxy;

-    *pts =  ts;

-    connkeep(conn, "HTTP proxy CONNECT");

-    return tunnel_reinit(ts, conn, data);

- @@ -210,7 +198,6 @@ static void tunnel_go_state(struct Curl_cfilter *cf,

-      Curl_dyn_reset(&ts->rcvbuf);

-      Curl_dyn_reset(&ts->req);

-      /* restore the protocol pointer */

- -    data->req.p.http = ts->prot_save;

-      data->info.httpcode = 0; /* clear it as it might've been used for the

-                                  proxy */

-      /* If a proxy-authorization header was used for the proxy, then we should

- @@ -338,7 +325,8 @@ static CURLcode start_CONNECT(struct Curl_easy *data,

-      goto out;

-  

-    /* Send the connect request to the proxy */

- -  result = Curl_buffer_send(&ts->req, data, &data->info.request_size, 0,

- +  result = Curl_buffer_send(&ts->req, data, &ts->CONNECT,

- +                            &data->info.request_size, 0,

-                              ts->sockindex);

-    ts->headerlines = 0;

-  

- @@ -356,7 +344,7 @@ static CURLcode send_CONNECT(struct Curl_easy *data,

-                               bool *done)

-  {

-    struct SingleRequest *k = &data->req;

- -  struct HTTP *http = data->req.p.http;

- +  struct HTTP *http = &ts->CONNECT;

-    CURLcode result = CURLE_OK;

-  

-    if(http->sending != HTTPSEND_REQUEST)

- @@ -377,7 +365,7 @@ static CURLcode send_CONNECT(struct Curl_easy *data,

-      result = Curl_write(data,

-                          conn->writesockfd,  /* socket to send to */

-                          k->upload_fromhere, /* buffer pointer */

- -                        ts->nsend,           /* buffer size */

- +                        ts->nsend,          /* buffer size */

-                          &bytes_written);    /* actually sent */

-      if(result)

-        goto out;

- @@ -1131,8 +1119,9 @@ static int http_proxy_cf_get_select_socks(struct Curl_cfilter *cf,

-           wait for the socket to become readable to be able to get the

-           response headers or if we're still sending the request, wait

-           for write. */

- -      if(ts->http_proxy.sending == HTTPSEND_REQUEST)

- +      if(ts->CONNECT.sending == HTTPSEND_REQUEST) {

-          return GETSOCK_WRITESOCK(0);

- +      }

-        return GETSOCK_READSOCK(0);

-      }

-      return GETSOCK_WRITESOCK(0);

- diff --git a/lib/rtsp.c b/lib/rtsp.c

- index 75e620d..80d1cf1 100644

- --- a/lib/rtsp.c

- +++ b/lib/rtsp.c

- @@ -592,7 +592,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)

-    }

-  

-    /* issue the request */

- -  result = Curl_buffer_send(&req_buffer, data,

- +  result = Curl_buffer_send(&req_buffer, data, data->req.p.http,

-                              &data->info.request_size, 0, FIRSTSOCKET);

-    if(result) {

-      failf(data, "Failed sending RTSP request");

- -- 

- 2.40.1

- 

@@ -1,59 +0,0 @@ 

- From c9828d86040737a47da862197b5def7ff6b0e3c4 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Mon, 6 Mar 2023 12:07:33 +0100

- Subject: [PATCH] telnet: only accept option arguments in ascii

- 

- To avoid embedded telnet negotiation commands etc.

- 

- Reported-by: Harry Sintonen

- Closes #10728

- 

- Upstream-commit: 538b1e79a6e7b0bb829ab4cecc828d32105d0684

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/telnet.c | 15 +++++++++++++++

-  1 file changed, 15 insertions(+)

- 

- diff --git a/lib/telnet.c b/lib/telnet.c

- index 22bc81e..baea885 100644

- --- a/lib/telnet.c

- +++ b/lib/telnet.c

- @@ -770,6 +770,17 @@ static void printsub(struct Curl_easy *data,

-    }

-  }

-  

- +static bool str_is_nonascii(const char *str)

- +{

- +  size_t len = strlen(str);

- +  while(len--) {

- +    if(*str & 0x80)

- +      return TRUE;

- +    str++;

- +  }

- +  return FALSE;

- +}

- +

-  static CURLcode check_telnet_options(struct Curl_easy *data)

-  {

-    struct curl_slist *head;

- @@ -784,6 +795,8 @@ static CURLcode check_telnet_options(struct Curl_easy *data)

-    /* Add the user name as an environment variable if it

-       was given on the command line */

-    if(data->state.aptr.user) {

- +   if(str_is_nonascii(data->conn->user))

- +     return CURLE_BAD_FUNCTION_ARGUMENT;

-      msnprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user);

-      beg = curl_slist_append(tn->telnet_vars, option_arg);

-      if(!beg) {

- @@ -798,6 +811,8 @@ static CURLcode check_telnet_options(struct Curl_easy *data)

-    for(head = data->set.telnet_options; head; head = head->next) {

-      if(sscanf(head->data, "%127[^= ]%*[ =]%255s",

-                option_keyword, option_arg) == 2) {

- +      if(str_is_nonascii(option_arg))

- +        continue;

-  

-        /* Terminal type */

-        if(strcasecompare(option_keyword, "TTYPE")) {

- -- 

- 2.39.2

- 

@@ -1,126 +0,0 @@ 

- From 5ebdef4442b438ab1a899edb169489fc259fae1a Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Thu, 9 Mar 2023 16:22:11 +0100

- Subject: [PATCH] curl_path: create the new path with dynbuf

- 

- Closes #10729

- 

- Upstream-commit: 4e2b52b5f7a3bf50a0f1494155717b02cc1df6d6

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/curl_path.c | 75 +++++++++++++++++++++++--------------------------

-  1 file changed, 35 insertions(+), 40 deletions(-)

- 

- diff --git a/lib/curl_path.c b/lib/curl_path.c

- index f00e3ee..8106042 100644

- --- a/lib/curl_path.c

- +++ b/lib/curl_path.c

- @@ -32,70 +32,65 @@

-  #include "escape.h"

-  #include "memdebug.h"

-  

- +#define MAX_SSHPATH_LEN 100000 /* arbitrary */

- +

-  /* figure out the path to work with in this particular request */

-  CURLcode Curl_getworkingpath(struct Curl_easy *data,

-                               char *homedir,  /* when SFTP is used */

-                               char **path) /* returns the  allocated

-                                               real path to work with */

-  {

- -  char *real_path = NULL;

-    char *working_path;

-    size_t working_path_len;

- +  struct dynbuf npath;

-    CURLcode result =

-      Curl_urldecode(data->state.up.path, 0, &working_path,

-                     &working_path_len, REJECT_ZERO);

-    if(result)

-      return result;

-  

- +  /* new path to switch to in case we need to */

- +  Curl_dyn_init(&npath, MAX_SSHPATH_LEN);

- +

-    /* Check for /~/, indicating relative to the user's home directory */

- -  if(data->conn->handler->protocol & CURLPROTO_SCP) {

- -    real_path = malloc(working_path_len + 1);

- -    if(!real_path) {

- +  if((data->conn->handler->protocol & CURLPROTO_SCP) &&

- +     (working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) {

- +    /* It is referenced to the home directory, so strip the leading '/~/' */

- +    if(Curl_dyn_addn(&npath, &working_path[3], working_path_len - 3)) {

-        free(working_path);

-        return CURLE_OUT_OF_MEMORY;

-      }

- -    if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))

- -      /* It is referenced to the home directory, so strip the leading '/~/' */

- -      memcpy(real_path, working_path + 3, working_path_len - 2);

- -    else

- -      memcpy(real_path, working_path, 1 + working_path_len);

-    }

- -  else if(data->conn->handler->protocol & CURLPROTO_SFTP) {

- -    if((working_path_len > 1) && (working_path[1] == '~')) {

- -      size_t homelen = strlen(homedir);

- -      real_path = malloc(homelen + working_path_len + 1);

- -      if(!real_path) {

- -        free(working_path);

- -        return CURLE_OUT_OF_MEMORY;

- -      }

- -      /* It is referenced to the home directory, so strip the

- -         leading '/' */

- -      memcpy(real_path, homedir, homelen);

- -      /* Only add a trailing '/' if homedir does not end with one */

- -      if(homelen == 0 || real_path[homelen - 1] != '/') {

- -        real_path[homelen] = '/';

- -        homelen++;

- -        real_path[homelen] = '\0';

- -      }

- -      if(working_path_len > 3) {

- -        memcpy(real_path + homelen, working_path + 3,

- -               1 + working_path_len -3);

- -      }

- +  else if((data->conn->handler->protocol & CURLPROTO_SFTP) &&

- +          (working_path_len > 2) && !memcmp(working_path, "/~/", 3)) {

- +    size_t len;

- +    const char *p;

- +    int copyfrom = 3;

- +    if(Curl_dyn_add(&npath, homedir)) {

- +      free(working_path);

- +      return CURLE_OUT_OF_MEMORY;

-      }

- -    else {

- -      real_path = malloc(working_path_len + 1);

- -      if(!real_path) {

- -        free(working_path);

- -        return CURLE_OUT_OF_MEMORY;

- -      }

- -      memcpy(real_path, working_path, 1 + working_path_len);

- +    /* Copy a separating '/' if homedir does not end with one */

- +    len = Curl_dyn_len(&npath);

- +    p = Curl_dyn_ptr(&npath);

- +    if(len && (p[len-1] != '/'))

- +      copyfrom = 2;

- +

- +    if(Curl_dyn_addn(&npath,

- +                     &working_path[copyfrom], working_path_len - copyfrom)) {

- +      free(working_path);

- +      return CURLE_OUT_OF_MEMORY;

-      }

-    }

-  

- -  free(working_path);

- +  if(Curl_dyn_len(&npath)) {

- +    free(working_path);

-  

- -  /* store the pointer for the caller to receive */

- -  *path = real_path;

- +    /* store the pointer for the caller to receive */

- +    *path = Curl_dyn_ptr(&npath);

- +  }

- +  else

- +    *path = working_path;

-  

-    return CURLE_OK;

-  }

- -- 

- 2.39.2

- 

@@ -1,166 +0,0 @@ 

- From b79a0e768fcd71003b33feb5deea697dd0903e48 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Thu, 9 Mar 2023 17:47:06 +0100

- Subject: [PATCH] ftp: add more conditions for connection reuse

- 

- Reported-by: Harry Sintonen

- Closes #10730

- 

- Upstream-commit: 8f4608468b890dce2dad9f91d5607ee7e9c1aba1

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/ftp.c     | 28 ++++++++++++++++++++++++++--

-  lib/ftp.h     |  5 +++++

-  lib/setopt.c  |  2 +-

-  lib/url.c     | 16 +++++++++++++++-

-  lib/urldata.h |  4 ++--

-  5 files changed, 49 insertions(+), 6 deletions(-)

- 

- diff --git a/lib/ftp.c b/lib/ftp.c

- index 8f0ac2e..d90509e 100644

- --- a/lib/ftp.c

- +++ b/lib/ftp.c

- @@ -4069,6 +4069,8 @@ static CURLcode ftp_disconnect(struct Curl_easy *data,

-    }

-  

-    freedirs(ftpc);

- +  Curl_safefree(ftpc->account);

- +  Curl_safefree(ftpc->alternative_to_user);

-    Curl_safefree(ftpc->prevpath);

-    Curl_safefree(ftpc->server_os);

-    Curl_pp_disconnect(pp);

- @@ -4338,11 +4340,31 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,

-    char *type;

-    struct FTP *ftp;

-    CURLcode result = CURLE_OK;

- +  struct ftp_conn *ftpc = &conn->proto.ftpc;

-  

- -  data->req.p.ftp = ftp = calloc(sizeof(struct FTP), 1);

- +  ftp = calloc(sizeof(struct FTP), 1);

-    if(!ftp)

-      return CURLE_OUT_OF_MEMORY;

-  

- +  /* clone connection related data that is FTP specific */

- +  if(data->set.str[STRING_FTP_ACCOUNT]) {

- +    ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]);

- +    if(!ftpc->account) {

- +      free(ftp);

- +      return CURLE_OUT_OF_MEMORY;

- +    }

- +  }

- +  if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]) {

- +    ftpc->alternative_to_user =

- +      strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);

- +    if(!ftpc->alternative_to_user) {

- +      Curl_safefree(ftpc->account);

- +      free(ftp);

- +      return CURLE_OUT_OF_MEMORY;

- +    }

- +  }

- +  data->req.p.ftp = ftp;

- +

-    ftp->path = &data->state.up.path[1]; /* don't include the initial slash */

-  

-    /* FTP URLs support an extension like ";type=<typecode>" that

- @@ -4377,7 +4399,9 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,

-    /* get some initial data into the ftp struct */

-    ftp->transfer = PPTRANSFER_BODY;

-    ftp->downloadsize = 0;

- -  conn->proto.ftpc.known_filesize = -1; /* unknown size for now */

- +  ftpc->known_filesize = -1; /* unknown size for now */

- +  ftpc->use_ssl = data->set.use_ssl;

- +  ftpc->ccc = data->set.ftp_ccc;

-  

-    return result;

-  }

- diff --git a/lib/ftp.h b/lib/ftp.h

- index 7f6f432..3f33e27 100644

- --- a/lib/ftp.h

- +++ b/lib/ftp.h

- @@ -119,6 +119,8 @@ struct FTP {

-     struct */

-  struct ftp_conn {

-    struct pingpong pp;

- +  char *account;

- +  char *alternative_to_user;

-    char *entrypath; /* the PWD reply when we logged on */

-    char *file;    /* url-decoded file name (or path) */

-    char **dirs;   /* realloc()ed array for path components */

- @@ -148,6 +150,9 @@ struct ftp_conn {

-    ftpstate state; /* always use ftp.c:state() to change state! */

-    ftpstate state_saved; /* transfer type saved to be reloaded after

-                             data connection is established */

- +  unsigned char use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or

- +                              IMAP or POP3 or others! (type: curl_usessl)*/

- +  unsigned char ccc;       /* ccc level for this connection */

-    curl_off_t retr_size_saved; /* Size of retrieved file saved */

-    char *server_os;     /* The target server operating system. */

-    curl_off_t known_filesize; /* file size is different from -1, if wildcard

- diff --git a/lib/setopt.c b/lib/setopt.c

- index f71a606..d1905c6 100644

- --- a/lib/setopt.c

- +++ b/lib/setopt.c

- @@ -2351,7 +2351,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)

-      arg = va_arg(param, long);

-      if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST))

-        return CURLE_BAD_FUNCTION_ARGUMENT;

- -    data->set.use_ssl = (curl_usessl)arg;

- +    data->set.use_ssl = (unsigned char)arg;

-      break;

-  

-    case CURLOPT_SSL_OPTIONS:

- diff --git a/lib/url.c b/lib/url.c

- index 831ae06..3b11b7e 100644

- --- a/lib/url.c

- +++ b/lib/url.c

- @@ -1352,10 +1352,24 @@ ConnectionExists(struct Curl_easy *data,

-           (data->state.httpwant < CURL_HTTP_VERSION_2_0))

-          continue;

-  

- -      if(get_protocol_family(needle->handler) == PROTO_FAMILY_SSH) {

- +#ifdef USE_SSH

- +      else if(get_protocol_family(needle->handler) == PROTO_FAMILY_SSH) {

-          if(!ssh_config_matches(needle, check))

-            continue;

-        }

- +#endif

- +#ifndef CURL_DISABLE_FTP

- +      else if(get_protocol_family(needle->handler) & PROTO_FAMILY_FTP) {

- +        /* Also match ACCOUNT, ALTERNATIVE-TO-USER, USE_SSL and CCC options */

- +        if(Curl_timestrcmp(needle->proto.ftpc.account,

- +                           check->proto.ftpc.account) ||

- +           Curl_timestrcmp(needle->proto.ftpc.alternative_to_user,

- +                           check->proto.ftpc.alternative_to_user) ||

- +           (needle->proto.ftpc.use_ssl != check->proto.ftpc.use_ssl) ||

- +           (needle->proto.ftpc.ccc != check->proto.ftpc.ccc))

- +          continue;

- +      }

- +#endif

-  

-        if((needle->handler->flags&PROTOPT_SSL)

-  #ifndef CURL_DISABLE_PROXY

- diff --git a/lib/urldata.h b/lib/urldata.h

- index 8c8c20b..ce90304 100644

- --- a/lib/urldata.h

- +++ b/lib/urldata.h

- @@ -1750,8 +1750,6 @@ struct UserDefined {

-  #ifndef CURL_DISABLE_NETRC

-    unsigned char use_netrc;        /* enum CURL_NETRC_OPTION values  */

-  #endif

- -  curl_usessl use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or

- -                            IMAP or POP3 or others! */

-    unsigned int new_file_perms;      /* when creating remote files */

-    unsigned int new_directory_perms; /* when creating remote dirs */

-    int ssh_auth_types;    /* allowed SSH auth types */

- @@ -1810,6 +1808,8 @@ struct UserDefined {

-    BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some

-                                  recipients */

-  #endif

- +  unsigned char use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or

- +                              IMAP or POP3 or others! (type: curl_usessl)*/

-    unsigned char connect_only; /* make connection/request, then let

-                                   application use the socket */

-    BIT(is_fread_set); /* has read callback been set to non-NULL? */

- -- 

- 2.39.2

- 

@@ -1,54 +0,0 @@ 

- From 9d6dd7bc1dea42ae8e710aeae714e2a2c290de61 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Fri, 10 Mar 2023 09:22:43 +0100

- Subject: [PATCH] url: only reuse connections with same GSS delegation

- 

- Reported-by: Harry Sintonen

- Closes #10731

- 

- Upstream-commit: cb49e67303dbafbab1cebf4086e3ec15b7d56ee5

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/url.c     | 6 ++++++

-  lib/urldata.h | 1 +

-  2 files changed, 7 insertions(+)

- 

- diff --git a/lib/url.c b/lib/url.c

- index 3b11b7e..cbbc7f3 100644

- --- a/lib/url.c

- +++ b/lib/url.c

- @@ -1345,6 +1345,11 @@ ConnectionExists(struct Curl_easy *data,

-          }

-        }

-  

- +      /* GSS delegation differences do not actually affect every connection

- +         and auth method, but this check takes precaution before efficiency */

- +      if(needle->gssapi_delegation != check->gssapi_delegation)

- +        continue;

- +

-        /* If multiplexing isn't enabled on the h2 connection and h1 is

-           explicitly requested, handle it: */

-        if((needle->handler->protocol & PROTO_FAMILY_HTTP) &&

- @@ -1662,6 +1667,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)

-    conn->fclosesocket = data->set.fclosesocket;

-    conn->closesocket_client = data->set.closesocket_client;

-    conn->lastused = Curl_now(); /* used now */

- +  conn->gssapi_delegation = data->set.gssapi_delegation;

-  

-    return conn;

-    error:

- diff --git a/lib/urldata.h b/lib/urldata.h

- index ce90304..9e16f26 100644

- --- a/lib/urldata.h

- +++ b/lib/urldata.h

- @@ -1111,6 +1111,7 @@ struct connectdata {

-    unsigned char ip_version; /* copied from the Curl_easy at creation time */

-    unsigned char httpversion; /* the HTTP version*10 reported by the server */

-    unsigned char connect_only;

- +  unsigned char gssapi_delegation; /* inherited from set.gssapi_delegation */

-  };

-  

-  /* The end of connectdata. */

- -- 

- 2.39.2

- 

@@ -1,40 +0,0 @@ 

- From ed7451520fd1b5da62a5371c07db69bed36a5486 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Thu, 9 Mar 2023 18:01:34 +0100

- Subject: [PATCH] CURLSHOPT_SHARE.3: HSTS sharing is not thread-safe

- 

- Reported-by: Hiroki Kurosawa

- Closes #10732

- 

- Upstream-commit: dca4cdf071be095bcdc7126eaa77a8946ea4790b

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  docs/libcurl/opts/CURLSHOPT_SHARE.3 | 5 +++--

-  1 file changed, 3 insertions(+), 2 deletions(-)

- 

- diff --git a/docs/libcurl/opts/CURLSHOPT_SHARE.3 b/docs/libcurl/opts/CURLSHOPT_SHARE.3

- index b15af82..4544160 100644

- --- a/docs/libcurl/opts/CURLSHOPT_SHARE.3

- +++ b/docs/libcurl/opts/CURLSHOPT_SHARE.3

- @@ -57,8 +57,7 @@ implemented until 7.23.0.

-  Put the connection cache in the share object and make all easy handles using

-  this share object share the connection cache.

-  

- -Note that due to a known bug, it is not safe to share connections this way

- -between multiple concurrent threads.

- +It is not supported to share connections between multiple concurrent threads.

-  

-  Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only

-  get additional transfers added to them if the existing connection is held by

- @@ -82,6 +81,8 @@ multi handle will share PSL cache by default without using this option.

-  .IP CURL_LOCK_DATA_HSTS

-  The in-memory HSTS cache.

-  

- +It is not supported to share the HSTS between multiple concurrent threads.

- +

-  Added in 7.88.0

-  .SH PROTOCOLS

-  All

- -- 

- 2.39.2

- 

@@ -1,30 +0,0 @@ 

- From 133e25afe4b8961b9c12334ee0bd3374db9a1fd4 Mon Sep 17 00:00:00 2001

- From: Daniel Stenberg <daniel@haxx.se>

- Date: Fri, 10 Mar 2023 08:22:51 +0100

- Subject: [PATCH] url: fix the SSH connection reuse check

- 

- Reported-by: Harry Sintonen

- Closes #10735

- 

- Upstream-commit: af369db4d3833272b8ed443f7fcc2e757a0872eb

- Signed-off-by: Kamil Dudka <kdudka@redhat.com>

- ---

-  lib/url.c | 2 +-

-  1 file changed, 1 insertion(+), 1 deletion(-)

- 

- diff --git a/lib/url.c b/lib/url.c

- index 0c31486..3b11b7e 100644

- --- a/lib/url.c

- +++ b/lib/url.c

- @@ -1353,7 +1353,7 @@ ConnectionExists(struct Curl_easy *data,

-          continue;

-  

-  #ifdef USE_SSH

- -      else if(get_protocol_family(needle->handler) == PROTO_FAMILY_SSH) {

- +      else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) {

-          if(!ssh_config_matches(needle, check))

-            continue;

-        }

- -- 

- 2.39.2

- 

@@ -0,0 +1,30 @@ 

+ From d506d885aa16b4a87acbac082eea41dccdc7b69f Mon Sep 17 00:00:00 2001

+ From: Kamil Dudka <kdudka@redhat.com>

+ Date: Wed, 15 Feb 2023 10:42:38 +0100

+ Subject: [PATCH] Revert "runtests: consider warnings fatal and error on them"

+ 

+ While it might be useful for upstream developers, it is not so useful

+ for downstream consumers.

+ 

+ This reverts upstream commit 22f795c834cfdbacbb1b55426028a581e3cf67a8.

+ ---

+  tests/runtests.pl | 3 +--

+  1 file changed, 1 insertion(+), 2 deletions(-)

+ 

+ diff --git a/tests/runtests.pl b/tests/runtests.pl

+ index 71644ad18..0cf85c3fe 100755

+ --- a/tests/runtests.pl

+ +++ b/tests/runtests.pl

+ @@ -75,8 +75,7 @@ BEGIN {

+  }

+  

+  use strict;

+ -# Promote all warnings to fatal

+ -use warnings FATAL => 'all';

+ +use warnings;

+  use Cwd;

+  use Digest::MD5 qw(md5);

+  use MIME::Base64;

+ -- 

+ 2.39.1

+ 

@@ -0,0 +1,97 @@ 

+ From c9a1d18e5f8f28b90c1b2fcc1f15699327067e59 Mon Sep 17 00:00:00 2001

+ From: Kamil Dudka <kdudka@redhat.com>

+ Date: Fri, 21 Apr 2023 17:44:10 +0200

+ Subject: [PATCH] tests/runtests.pl: attempt to fix a conflict on port numbers

+ 

+ ... where stunnel listens for legacy HTTPS and HTTP/2, which manifests

+ as a hard-to-explain failure of the following tests: 1630 1631 1632 1904

+ 1941 1945 2050 2055 3028

+ ```

+ [...]

+ startnew: perl -I../../tests ../../tests/secureserver.pl --pidfile ".https_server.pid" --logfile "log/https_stunnel.log" --ipv4 --proto https --stunnel "/usr/bin/stunnel" --srcdir "../../tests" --connect 42917 --accept 24642

+ RUN: HTTPS server is PID 114398 port 24642

+ * pid https => 114398 114402

+ [...]

+ startnew: perl -I../../tests ../../tests/secureserver.pl --pidfile ".https2_server.pid" --logfile "log/https2_stunnel.log" --id 2 --ipv4 --proto https --stunnel "/usr/bin/stunnel" --srcdir "../../tests" --connect 36763 --accept 24642

+ startnew: child process has died, server might start up

+ Warning: http2 server unexpectedly alive

+ RUN: Process with pid 73992 signalled to die

+ RUN: Process with pid 73992 forced to die with SIGKILL

+ == Contents of files in the log/ dir after test 1630

+ === Start of file http2_server.log

+  14:01:21.881018 exit_signal_handler: 15

+  14:01:21.881372 signalled to die

+  14:01:21.881511 ========> IPv4 sws (port 36763 pid: 73992) exits with signal (15)

+ === End of file http2_server.log

+ === Start of file https2_stunnel.log

+  [ ] Initializing inetd mode configuration

+  [ ] Clients allowed=500

+  [.] stunnel 5.69 on x86_64-redhat-linux-gnu platform

+  [.] Compiled/running with OpenSSL 3.0.8 7 Feb 2023

+  [.] Threading:PTHREAD Sockets:POLL,IPv6 TLS:ENGINE,FIPS,OCSP,PSK,SNI

+  [ ] errno: (*__errno_location ())

+  [ ] Initializing inetd mode configuration

+  [.] Reading configuration from file /builddir/build/BUILD/curl-8.0.1/build-minimal/tests/https_stunnel.conf

+  [.] UTF-8 byte order mark not detected

+  [.] FIPS mode disabled

+  [ ] Compression disabled

+  [ ] No PRNG seeding was required

+  [ ] Initializing service [curltest]

+  [ ] Using the default TLS minimum version as specified in crypto policies. Not setting explicitly.

+  [ ] Using the default TLS maximum version as specified in crypto policies. Not setting explicitly

+  [ ] stunnel default security level set: 2

+  [ ] Ciphers: PROFILE=SYSTEM

+  [ ] TLSv1.3 ciphersuites: TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256

+  [ ] TLS options: 0x2100000 (+0x0, -0x0)

+  [ ] Session resumption enabled

+  [ ] Loading certificate from file: /builddir/build/BUILD/curl-8.0.1/tests/stunnel.pem

+  [ ] Certificate loaded from file: /builddir/build/BUILD/curl-8.0.1/tests/stunnel.pem

+  [ ] Loading private key from file: /builddir/build/BUILD/curl-8.0.1/tests/stunnel.pem

+  [ ] Private key loaded from file: /builddir/build/BUILD/curl-8.0.1/tests/stunnel.pem

+  [ ] Private key check succeeded

+  [!] No trusted certificates found

+  [ ] DH initialization needed for DHE-RSA-AES256-GCM-SHA384

+  [ ] DH initialization

+  [ ] Could not load DH parameters from /builddir/build/BUILD/curl-8.0.1/tests/stunnel.pem

+  [ ] Using dynamic DH parameters

+  [ ] ECDH initialization

+  [ ] ECDH initialized with curves X25519:P-256:X448:P-521:P-384

+  [.] Configuration successful

+  [ ] Deallocating deployed section defaults

+  [ ] Binding service [curltest]

+  [ ] Listening file descriptor created (FD=8)

+  [ ] Setting accept socket options (FD=8)

+  [ ] Option SO_REUSEADDR set on accept socket

+  [.] Binding service [curltest] to 0.0.0.0:24642: Address already in use (98)

+  [ ] Listening file descriptor created (FD=8)

+  [ ] Setting accept socket options (FD=8)

+  [ ] Option SO_REUSEADDR set on accept socket

+  [.] Binding service [curltest] to :::24642: Address already in use (98)

+  [!] Binding service [curltest] failed

+  [ ] Unbinding service [curltest]

+  [ ] Service [curltest] closed

+  [ ] Deallocating deployed section defaults

+  [ ] Deallocating section [curltest]

+  [ ] Initializing inetd mode configuration

+ === End of file https2_stunnel.log

+ ```

+ ---

+  tests/runtests.pl | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/tests/runtests.pl b/tests/runtests.pl

+ index 54f6923..bb362c9 100755

+ --- a/tests/runtests.pl

+ +++ b/tests/runtests.pl

+ @@ -1802,7 +1802,7 @@ sub runhttpsserver {

+  

+      my $pid2;

+      my $httpspid;

+ -    my $port = 24512; # start attempt

+ +    my $port = 24512 * $idnum; # start attempt

+      for (1 .. 10) {

+          $port += int(rand(600));

+          my $options = "$flags --accept $port";

+ -- 

+ 2.39.2

+ 

file modified
+21 -91
@@ -1,7 +1,7 @@ 

  Summary: A utility for getting files from remote servers (FTP, HTTP, and others)

  Name: curl

- Version: 7.87.0

- Release: 10%{?dist}

+ Version: 8.0.1

+ Release: 1%{?dist}

  License: MIT

  Source0: https://curl.se/download/%{name}-%{version}.tar.xz

  Source1: https://curl.se/download/%{name}-%{version}.tar.xz.asc
@@ -10,45 +10,6 @@ 

  # which points to the GPG key as of April 7th 2016 of https://daniel.haxx.se/mykey.asc

  Source2: mykey.asc

  

- # fix regression in a public header file (#2162716)

- Patch1:   0001-curl-7.87.0-header-file-regression.patch

- 

- # tests: make sure gnuserv-tls has SRP support before using it

- Patch2:   0002-curl-7.87.0-tests-tls-srp.patch

- 

- # cfilters: use the first non-connected filter (#2185433)

- Patch3:   0003-curl-7.87.0-cfilters-ostree.patch

- 

- # share HSTS between handles (CVE-2023-23915 CVE-2023-23914)

- Patch6:   0006-curl-7.87.0-hsts-CVEs.patch

- 

- # fix HTTP multi-header compression denial of service (CVE-2023-23916)

- Patch7:   0007-curl-7.87.0-CVE-2023-23916.patch

- 

- # vtls: fix hostname handling in filters (#2192665)

- Patch8:   0008-curl-7.87.0-vtls-hostname.patch

- 

- # http_proxy: fix memory corruption with http proxy tunneling (#2192665)

- Patch9:   0009-curl-7.87.0-http-proxy.patch

- 

- # fix TELNET option IAC injection (CVE-2023-27533)

- Patch23:  0023-curl-7.87.0-CVE-2023-27533.patch

- 

- # fix SFTP path ~ resolving discrepancy (CVE-2023-27534)

- Patch24:  0024-curl-7.87.0-CVE-2023-27534.patch

- 

- # fix FTP too eager connection reuse (CVE-2023-27535)

- Patch25:  0025-curl-7.87.0-CVE-2023-27535.patch

- 

- # fix GSS delegation too eager connection re-use (CVE-2023-27536)

- Patch26:  0026-curl-7.87.0-CVE-2023-27536.patch

- 

- # fix HSTS double-free (CVE-2023-27537)

- Patch27:  0027-curl-7.87.0-CVE-2023-27537.patch

- 

- # fix SSH connection too eager reuse still (CVE-2023-27538)

- Patch28:  0028-curl-7.87.0-CVE-2023-27538.patch

- 

  # patch making libcurl multilib ready

  Patch101: 0101-curl-7.32.0-multilib.patch

  
@@ -58,6 +19,12 @@ 

  # test3012: temporarily disable valgrind (#2143040)

  Patch103: 0103-curl-7.87.0-test3012.patch

  

+ # do not fail on warnings in the upstream test driver

+ Patch104: 0104-curl-7.88.0-tests-warnings.patch

+ 

+ # tests: attempt to fix a conflict on port numbers

+ Patch105: 0105-curl-8.0.1-tests-stunnel-port.patch

+ 

  Provides: curl-full = %{version}-%{release}

  Provides: webclient

  URL: https://curl.se/
@@ -96,6 +63,9 @@ 

  BuildRequires: perl(strict)

  BuildRequires: perl(warnings)

  

+ # needed for test1560 to succeed

+ BuildRequires: glibc-langpack-en

+ 

  # gnutls-serv is used by the upstream test-suite

  BuildRequires: gnutls-utils

  
@@ -233,57 +203,11 @@ 

  

  %prep

  %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'

- %setup -q

- 

- # upstream patches

- %patch1 -p1

- %patch2 -p1

- %patch3 -p1

- %patch6 -p1

- %patch7 -p1

- %patch8 -p1

- %patch9 -p1

- %patch23 -p1

- %patch24 -p1

- %patch25 -p1

- %patch26 -p1

- %patch27 -p1

- %patch28 -p1

- 

- # Fedora patches

- %patch101 -p1

- %patch102 -p1

- %patch103 -p1

- 

- # disable test 1112 (#565305), test 1455 (occasionally fails with 'bind failed

- # with errno 98: Address already in use' in Koji environment), and test 1801

- # <https://github.com/bagder/curl/commit/21e82bd6#commitcomment-12226582>

- printf "1112\n1455\n1184\n1801\n" >> tests/data/DISABLED

- 

- # disable test 1319 on ppc64 (server times out)

- %ifarch ppc64

- echo "1319" >> tests/data/DISABLED

- %endif

- 

- # disable tests 320..322 on ppc64le where it started to hang/fail

- %ifarch ppc64le

- printf "320\n321\n322\n" >> tests/data/DISABLED

- %endif

- 

- # temporarily disable tests 582 and 1452 on s390x (client times out)

- %ifarch s390x

- printf "582\n1452\n" >> tests/data/DISABLED

- %endif

- 

- # temporarily disable tests 702 703 716 on armv7hl (#1829180)

- %ifarch armv7hl

- printf "702\n703\n716\n" >> tests/data/DISABLED

- %endif

+ %autosetup -p1

  

- # temporarily disable tests 300{0,1} on x86_64 (stunnel clashes with itself)

- %ifarch x86_64

- printf "3000\n3001\n" >> tests/data/DISABLED

- %endif

+ # disable test 1801

+ # <https://github.com/bagder/curl/commit/21e82bd6#commitcomment-12226582>

+ echo "1801" >> tests/data/DISABLED

  

  # test3026: avoid pthread_create() failure due to resource exhaustion on i386

  %ifarch %{ix86}
@@ -483,6 +407,12 @@ 

  %{_libdir}/libcurl.so.4.[0-9].[0-9].minimal

  

  %changelog

+ * Wed May 03 2023 Kamil Dudka <kdudka@redhat.com> - 8.0.1-1

+ - tests: re-enable temporarily disabled test-cases

+ - tests: attempt to fix a conflict on port numbers

+ - apply patches automatically

+ - rebase to latest upstream release (#2192665)

+ 

  * Wed May 03 2023 Kamil Dudka <kdudka@redhat.com> - 7.87.0-10

  - http_proxy: fix memory corruption with http proxy tunneling (#2192665)

  

file modified
+2 -2
@@ -1,2 +1,2 @@ 

- SHA512 (curl-7.87.0.tar.xz) = aa125991592667280dce3788aabe81487cf8c55b0afc59d675cc30b76055bb7114f5380b4a0e3b6461a8f81bf9812fa26d493a85f7e01d84263d484a0d699ee7

- SHA512 (curl-7.87.0.tar.xz.asc) = 0bcc12bafc4ae50d80128af2cf4bf1a1ec6018ebb8d5b9c49f52b51c0c25acc77e820858965656549ef43c1f923f4e5fe75b0a3523623154b4cfb9dc8a1d76e4

+ SHA512 (curl-8.0.1.tar.xz) = 3bb777982659ed697ae90f113ff7b65d6ce8ba9fe6a8984cfd6769d2f051a72ba953c911abe234c204ec2cc5a35d68b4d033037fad7fba31bb92a52543f8d13d

+ SHA512 (curl-8.0.1.tar.xz.asc) = 92c6a0570e9a8a708fe2f717b8b37a68dcb9cd4520ca50c9baafec5891bda103bce2d2dcb67f1387bf11bd7e51e0e64ccd52d196e61d58b598ad3aa1960386cf

  • tests: re-enable temporarily disabled test-cases
  • tests: attempt to fix a conflict on port numbers
  • apply patches automatically
  • rebase to latest upstream release (#2192665)

rebased onto d1637f95797aa0a4b71391b9f131f4fa30a38248

a year ago

rebased onto f854769

a year ago

6 new commits added

  • tests: re-enable temporarily disabled test-cases
  • tests: attempt to fix a conflict on port numbers
  • curl.spec: apply patches automatically
  • add glibc-langpack-en BR needed for test1560 to succeed
  • do not fail on warnings in the upstream test driver
  • Resolves: #2192665 - new upstream release - 8.0.1
a year ago

Pull-Request has been merged by kdudka

a year ago