0001-vtsl-eliminate-data-state-ssl_scache.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. https://github.com/curl/curl/issues/16236#issuecomment-2645385845
  2. https://github.com/curl/curl/commit/242a1439e7d8cdb72ae6a2fa2e705e2d9a2b7501
  3. Fixes curl bug https://github.com/curl/curl/issues/16236 "that caused
  4. a segfault in kodi".
  5. Instead of adding upstream commit
  6. https://github.com/curl/curl/commit/242a1439e7d8cdb72ae6a2fa2e705e2d9a2b7501
  7. which does not apply cleanly on libcurl 8.12.0 we use the Gentoo version:
  8. https://github.com/gentoo/gentoo/blob/master/net-misc/curl/files/curl-8.12.0-multi.patch
  9. Upstream: https://github.com/curl/curl/commit/242a1439e7d8cdb72ae6a2fa2e705e2d9a2b7501
  10. Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
  11. --- a/lib/setopt.c
  12. +++ b/lib/setopt.c
  13. @@ -1584,10 +1584,6 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
  14. if(data->share->hsts == data->hsts)
  15. data->hsts = NULL;
  16. #endif
  17. -#ifdef USE_SSL
  18. - if(data->share->ssl_scache == data->state.ssl_scache)
  19. - data->state.ssl_scache = data->multi ? data->multi->ssl_scache : NULL;
  20. -#endif
  21. #ifdef USE_LIBPSL
  22. if(data->psl == &data->share->psl)
  23. data->psl = data->multi ? &data->multi->psl : NULL;
  24. @@ -1628,10 +1624,6 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
  25. data->hsts = data->share->hsts;
  26. }
  27. #endif
  28. -#ifdef USE_SSL
  29. - if(data->share->ssl_scache)
  30. - data->state.ssl_scache = data->share->ssl_scache;
  31. -#endif
  32. #ifdef USE_LIBPSL
  33. if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
  34. data->psl = &data->share->psl;
  35. --- a/lib/transfer.c
  36. +++ b/lib/transfer.c
  37. @@ -567,12 +567,6 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
  38. #endif
  39. data->state.httpreq = data->set.method;
  40. -#ifdef USE_SSL
  41. - if(!data->state.ssl_scache)
  42. - /* There was no ssl session cache set via a share, use the multi one */
  43. - data->state.ssl_scache = data->multi->ssl_scache;
  44. -#endif
  45. -
  46. data->state.requests = 0;
  47. data->state.followlocation = 0; /* reset the location-follow counter */
  48. data->state.this_is_a_follow = FALSE; /* reset this */
  49. --- a/lib/urldata.h
  50. +++ b/lib/urldata.h
  51. @@ -1199,7 +1199,6 @@ struct UrlState {
  52. curl_prot_t first_remote_protocol;
  53. int retrycount; /* number of retries on a new connection */
  54. - struct Curl_ssl_scache *ssl_scache; /* TLS session pool */
  55. int os_errno; /* filled in with errno whenever an error occurs */
  56. long followlocation; /* redirect counter */
  57. int requests; /* request counter: redirects + authentication retakes */
  58. --- a/lib/vtls/vtls_scache.c
  59. +++ b/lib/vtls/vtls_scache.c
  60. @@ -82,6 +82,17 @@ struct Curl_ssl_scache {
  61. long age;
  62. };
  63. +static struct Curl_ssl_scache *cf_ssl_scache_get(struct Curl_easy *data)
  64. +{
  65. + struct Curl_ssl_scache *scache = NULL;
  66. + /* If a share is present, its ssl_scache has preference over the multi */
  67. + if(data->share && data->share->ssl_scache)
  68. + scache = data->share->ssl_scache;
  69. + else if(data->multi && data->multi->ssl_scache)
  70. + scache = data->multi->ssl_scache;
  71. + return scache;
  72. +}
  73. +
  74. static void cf_ssl_scache_clear_session(struct Curl_ssl_session *s)
  75. {
  76. if(s->sdata) {
  77. @@ -792,7 +803,7 @@ CURLcode Curl_ssl_scache_put(struct Curl_cfilter *cf,
  78. const char *ssl_peer_key,
  79. struct Curl_ssl_session *s)
  80. {
  81. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  82. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  83. struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
  84. CURLcode result;
  85. DEBUGASSERT(ssl_config);
  86. @@ -826,7 +837,7 @@ CURLcode Curl_ssl_scache_take(struct Curl_cfilter *cf,
  87. const char *ssl_peer_key,
  88. struct Curl_ssl_session **ps)
  89. {
  90. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  91. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  92. struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
  93. struct Curl_ssl_scache_peer *peer = NULL;
  94. struct Curl_llist_node *n;
  95. @@ -870,7 +881,7 @@ CURLcode Curl_ssl_scache_add_obj(struct Curl_cfilter *cf,
  96. void *sobj,
  97. Curl_ssl_scache_obj_dtor *sobj_free)
  98. {
  99. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  100. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  101. struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
  102. struct Curl_ssl_scache_peer *peer = NULL;
  103. CURLcode result;
  104. @@ -898,7 +909,7 @@ bool Curl_ssl_scache_get_obj(struct Curl_cfilter *cf,
  105. const char *ssl_peer_key,
  106. void **sobj)
  107. {
  108. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  109. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  110. struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
  111. struct Curl_ssl_scache_peer *peer = NULL;
  112. CURLcode result;
  113. @@ -924,7 +935,7 @@ void Curl_ssl_scache_remove_all(struct Curl_cfilter *cf,
  114. struct Curl_easy *data,
  115. const char *ssl_peer_key)
  116. {
  117. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  118. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  119. struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
  120. struct Curl_ssl_scache_peer *peer = NULL;
  121. CURLcode result;
  122. @@ -1021,7 +1032,7 @@ CURLcode Curl_ssl_session_import(struct Curl_easy *data,
  123. const unsigned char *shmac, size_t shmac_len,
  124. const unsigned char *sdata, size_t sdata_len)
  125. {
  126. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  127. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  128. struct Curl_ssl_scache_peer *peer = NULL;
  129. struct Curl_ssl_session *s = NULL;
  130. bool locked = FALSE;
  131. @@ -1092,7 +1103,7 @@ CURLcode Curl_ssl_session_export(struct Curl_easy *data,
  132. curl_ssls_export_cb *export_fn,
  133. void *userptr)
  134. {
  135. - struct Curl_ssl_scache *scache = data->state.ssl_scache;
  136. + struct Curl_ssl_scache *scache = cf_ssl_scache_get(data);
  137. struct Curl_ssl_scache_peer *peer;
  138. struct dynbuf sbuf, hbuf;
  139. struct Curl_llist_node *n;