{"thread":{"id":"59106","subject":"[PATCH] curl: resolve deprecated curl declarations","startedAt":"2023-01-17T21:01:40Z","lastAt":"2023-01-17T21:48:16Z","messageCount":4,"participants":["Rose via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"470529","messageId":"pull.1435.git.git.1673983640663.gitgitgadget@gmail.com","threadId":"59106","inReplyTo":null,"subject":"[PATCH] curl: resolve deprecated curl declarations","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-17T19:27:20Z","receivedAt":"2023-01-17T21:01:40Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFix CI-Alpine build by replacing deprecated\ndeclarations with their suggested replacements\n\nNote that this required changing the\ncallbacks of functions because the replacement\nfor these deprecations require a different function\nsignature for the callback and different parameters.\n\nEvery change done was made as to minimize\nchanged behavior as well as get the CI to pass again.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    curl: resolve deprecated curl declarations\n    \n    Fix CI-Alpine build by replacing deprecated declarations with their\n    suggested replacements\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1435%2FAtariDreams%2Fcurl-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1435/AtariDreams/curl-v1\nPull-Request: https://github.com/git/git/pull/1435\n\n git-curl-compat.h |  8 +++++\n http-push.c       |  6 ++--\n http.c            | 74 ++++++++++++++++++++++++++++++++++++++---------\n http.h            |  2 +-\n remote-curl.c     | 28 +++++++-----------\n 5 files changed, 83 insertions(+), 35 deletions(-)\n\ndiff --git a/git-curl-compat.h b/git-curl-compat.h\nindex 56a83b6bbd8..a2e6ad79b09 100644\n--- a/git-curl-compat.h\n+++ b/git-curl-compat.h\n@@ -127,3 +127,11 @@\n #endif\n \n #endif\n+\n+/**\n+ * CURLOPT_REDIR_PROTOCOLS_STR was added in 7.83.0, released in August\n+ * 2022.\n+ */\n+#if LIBCURL_VERSION_NUM >= 0x075500\n+#define GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR 1\n+#endif\ndiff --git a/http-push.c b/http-push.c\nindex 5f4340a36e6..ab458d4d062 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -198,13 +198,13 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, ioctl_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n \tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\ndiff --git a/http.c b/http.c\nindex 8a5ba3f4776..60bc84ab9a3 100644\n--- a/http.c\n+++ b/http.c\n@@ -157,21 +157,12 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n \treturn size / eltsize;\n }\n \n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n+int ioctl_buffer(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct buffer *buffer = clientp;\n+\tstruct buffer *buffer = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tbuffer->posn = 0;\n-\t\treturn CURLIOE_OK;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n-\t}\n+\tbuffer->posn = 0;\n+\treturn CURL_SEEKFUNC_OK;\n }\n \n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n@@ -765,7 +756,52 @@ void setup_curl_trace(CURL *handle)\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n }\n+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n+static void get_curl_allowed_protocols(int from_user, char *protocol)\n+{\n+\tunsigned int i = 0;\n+\n+\tif (is_transport_allowed(\"http\", from_user)) {\n+\t\tprotocol[i++] = 'h';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t}\n+\n+\tif (is_transport_allowed(\"https\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol[i++] = 'h';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t\tprotocol[i++] = 's';\n+\t}\n+\tif (is_transport_allowed(\"ftp\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n \n+\t\tprotocol[i++] = 'f';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t}\n+\tif (is_transport_allowed(\"ftps\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol[i++] = 'f';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t\tprotocol[i++] = 's';\n+\t}\n+\n+\tprotocol[i] = '\\0';\n+}\n+#else\n static long get_curl_allowed_protocols(int from_user)\n {\n \tlong allowed_protocols = 0;\n@@ -781,6 +817,7 @@ static long get_curl_allowed_protocols(int from_user)\n \n \treturn allowed_protocols;\n }\n+#endif\n \n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n@@ -810,6 +847,9 @@ static int get_curl_http_version_opt(const char *version_string, long *opt)\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n+\tstatic char protocol[20], redir_protocol[20];\n+#endif\n \n \tif (!result)\n \t\tdie(\"curl_easy_init failed\");\n@@ -923,10 +963,18 @@ static CURL *get_curl_handle(void)\n \n \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n+\tget_curl_allowed_protocols(0, redir_protocol);\n+\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n+\tget_curl_allowed_protocols(-1, protocol);\n+\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol);\n+#else\n \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(0));\n \tcurl_easy_setopt(result, CURLOPT_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(-1));\n+#endif\n+\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\thttp_trace_curl_no_data();\n \tsetup_curl_trace(result);\ndiff --git a/http.h b/http.h\nindex 3c94c479100..0ec572d4a06 100644\n--- a/http.h\n+++ b/http.h\n@@ -40,7 +40,7 @@ struct buffer {\n size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n+int ioctl_buffer(void *userp, curl_off_t offset, int origin);\n \n /* Slot lifecycle functions */\n struct active_request_slot *get_active_slot(void);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 72dfb8fb86a..ae69dcb70d5 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -717,25 +717,17 @@ static size_t rpc_out(void *ptr, size_t eltsize,\n \treturn avail;\n }\n \n-static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n+static int rpc_ioctl(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct rpc_state *rpc = clientp;\n+\tstruct rpc_state *rpc = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tif (rpc->initial_buffer) {\n-\t\t\trpc->pos = 0;\n-\t\t\treturn CURLIOE_OK;\n-\t\t}\n-\t\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n-\t\treturn CURLIOE_FAILRESTART;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\tif (rpc->initial_buffer) {\n+\t\trpc->pos = 0;\n+\t\treturn CURL_SEEKFUNC_OK;\n \t}\n+\n+\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n+\treturn CURL_SEEKFUNC_FAIL;\n }\n \n struct check_pktline_state {\n@@ -959,8 +951,8 @@ retry:\n \t\trpc->initial_buffer = 1;\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_ioctl);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);\n \t\tif (options.verbosity > 1) {\n \t\t\tfprintf(stderr, \"POST %s (chunked)\\n\", rpc->service_name);\n \t\t\tfflush(stderr);\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"},{"id":"470538","messageId":"pull.1435.v2.git.git.1673984591615.gitgitgadget@gmail.com","threadId":"59106","inReplyTo":"pull.1435.git.git.1673983640663.gitgitgadget@gmail.com","subject":"[PATCH v2] curl: resolve deprecated curl declarations","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-17T19:43:11Z","receivedAt":"2023-01-17T21:25:44Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFix CI-Alpine build by replacing deprecated\ndeclarations with their suggested replacements\n\nNote that this required changing the\ncallbacks of functions because the replacement\nfor these deprecations require a different function\nsignature for the callback and different parameters.\n\nEvery change done was made as to minimize\nchanged behavior as well as get the CI to pass again.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    curl: resolve deprecated curl declarations\n    \n    Fix CI-Alpine build by replacing deprecated declarations with their\n    suggested replacements\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1435%2FAtariDreams%2Fcurl-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1435/AtariDreams/curl-v2\nPull-Request: https://github.com/git/git/pull/1435\n\nRange-diff vs v1:\n\n 1:  d84e7e003da ! 1:  c40fb2de13d curl: resolve deprecated curl declarations\n     @@ git-curl-compat.h\n       #endif\n      +\n      +/**\n     -+ * CURLOPT_REDIR_PROTOCOLS_STR was added in 7.83.0, released in August\n     ++ * CURLOPT_PROTOCOLS_STR was added in 7.83.0, released in August\n      + * 2022.\n      + */\n      +#if LIBCURL_VERSION_NUM >= 0x075500\n     -+#define GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR 1\n     ++#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1\n      +#endif\n      \n       ## http-push.c ##\n     @@ http.c: void setup_curl_trace(CURL *handle)\n       \tcurl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);\n       \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n       }\n     -+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n     ++#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n      +static void get_curl_allowed_protocols(int from_user, char *protocol)\n      +{\n      +\tunsigned int i = 0;\n     @@ http.c: static int get_curl_http_version_opt(const char *version_string, long *o\n       static CURL *get_curl_handle(void)\n       {\n       \tCURL *result = curl_easy_init();\n     -+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n     ++#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n      +\tstatic char protocol[20], redir_protocol[20];\n      +#endif\n       \n     @@ http.c: static CURL *get_curl_handle(void)\n       \n       \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n       \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n     -+#ifdef GIT_CURL_HAVE_OPT_REDIR_PROTOCOLS_STR\n     ++#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n      +\tget_curl_allowed_protocols(0, redir_protocol);\n      +\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n      +\tget_curl_allowed_protocols(-1, protocol);\n\n\n git-curl-compat.h |  8 +++++\n http-push.c       |  6 ++--\n http.c            | 74 ++++++++++++++++++++++++++++++++++++++---------\n http.h            |  2 +-\n remote-curl.c     | 28 +++++++-----------\n 5 files changed, 83 insertions(+), 35 deletions(-)\n\ndiff --git a/git-curl-compat.h b/git-curl-compat.h\nindex 56a83b6bbd8..38a2237c8fe 100644\n--- a/git-curl-compat.h\n+++ b/git-curl-compat.h\n@@ -127,3 +127,11 @@\n #endif\n \n #endif\n+\n+/**\n+ * CURLOPT_PROTOCOLS_STR was added in 7.83.0, released in August\n+ * 2022.\n+ */\n+#if LIBCURL_VERSION_NUM >= 0x075500\n+#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1\n+#endif\ndiff --git a/http-push.c b/http-push.c\nindex 5f4340a36e6..ab458d4d062 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -198,13 +198,13 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, ioctl_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n \tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\ndiff --git a/http.c b/http.c\nindex 8a5ba3f4776..ee5f063e5b0 100644\n--- a/http.c\n+++ b/http.c\n@@ -157,21 +157,12 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n \treturn size / eltsize;\n }\n \n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n+int ioctl_buffer(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct buffer *buffer = clientp;\n+\tstruct buffer *buffer = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tbuffer->posn = 0;\n-\t\treturn CURLIOE_OK;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n-\t}\n+\tbuffer->posn = 0;\n+\treturn CURL_SEEKFUNC_OK;\n }\n \n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n@@ -765,7 +756,52 @@ void setup_curl_trace(CURL *handle)\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n }\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+static void get_curl_allowed_protocols(int from_user, char *protocol)\n+{\n+\tunsigned int i = 0;\n+\n+\tif (is_transport_allowed(\"http\", from_user)) {\n+\t\tprotocol[i++] = 'h';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t}\n+\n+\tif (is_transport_allowed(\"https\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol[i++] = 'h';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t\tprotocol[i++] = 's';\n+\t}\n+\tif (is_transport_allowed(\"ftp\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n \n+\t\tprotocol[i++] = 'f';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t}\n+\tif (is_transport_allowed(\"ftps\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol[i++] = 'f';\n+\t\tprotocol[i++] = 't';\n+\t\tprotocol[i++] = 'p';\n+\t\tprotocol[i++] = 's';\n+\t}\n+\n+\tprotocol[i] = '\\0';\n+}\n+#else\n static long get_curl_allowed_protocols(int from_user)\n {\n \tlong allowed_protocols = 0;\n@@ -781,6 +817,7 @@ static long get_curl_allowed_protocols(int from_user)\n \n \treturn allowed_protocols;\n }\n+#endif\n \n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n@@ -810,6 +847,9 @@ static int get_curl_http_version_opt(const char *version_string, long *opt)\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+\tstatic char protocol[20], redir_protocol[20];\n+#endif\n \n \tif (!result)\n \t\tdie(\"curl_easy_init failed\");\n@@ -923,10 +963,18 @@ static CURL *get_curl_handle(void)\n \n \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+\tget_curl_allowed_protocols(0, redir_protocol);\n+\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n+\tget_curl_allowed_protocols(-1, protocol);\n+\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol);\n+#else\n \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(0));\n \tcurl_easy_setopt(result, CURLOPT_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(-1));\n+#endif\n+\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\thttp_trace_curl_no_data();\n \tsetup_curl_trace(result);\ndiff --git a/http.h b/http.h\nindex 3c94c479100..0ec572d4a06 100644\n--- a/http.h\n+++ b/http.h\n@@ -40,7 +40,7 @@ struct buffer {\n size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n+int ioctl_buffer(void *userp, curl_off_t offset, int origin);\n \n /* Slot lifecycle functions */\n struct active_request_slot *get_active_slot(void);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 72dfb8fb86a..ae69dcb70d5 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -717,25 +717,17 @@ static size_t rpc_out(void *ptr, size_t eltsize,\n \treturn avail;\n }\n \n-static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n+static int rpc_ioctl(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct rpc_state *rpc = clientp;\n+\tstruct rpc_state *rpc = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tif (rpc->initial_buffer) {\n-\t\t\trpc->pos = 0;\n-\t\t\treturn CURLIOE_OK;\n-\t\t}\n-\t\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n-\t\treturn CURLIOE_FAILRESTART;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\tif (rpc->initial_buffer) {\n+\t\trpc->pos = 0;\n+\t\treturn CURL_SEEKFUNC_OK;\n \t}\n+\n+\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n+\treturn CURL_SEEKFUNC_FAIL;\n }\n \n struct check_pktline_state {\n@@ -959,8 +951,8 @@ retry:\n \t\trpc->initial_buffer = 1;\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_ioctl);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);\n \t\tif (options.verbosity > 1) {\n \t\t\tfprintf(stderr, \"POST %s (chunked)\\n\", rpc->service_name);\n \t\t\tfflush(stderr);\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"},{"id":"470541","messageId":"pull.1435.v3.git.git.1673985725868.gitgitgadget@gmail.com","threadId":"59106","inReplyTo":"pull.1435.v2.git.git.1673984591615.gitgitgadget@gmail.com","subject":"[PATCH v3] curl: resolve deprecated curl declarations","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-17T20:02:05Z","receivedAt":"2023-01-17T21:39:43Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFix CI-Alpine build by replacing deprecated\ndeclarations with their suggested replacements\n\nNote that this required changing the\ncallbacks of functions because the replacement\nfor these deprecations require a different function\nsignature for the callback and different parameters.\n\nEvery change done was made as to minimize\nchanged behavior as well as get the CI to pass again.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    curl: resolve deprecated curl declarations\n    \n    Fix CI-Alpine build by replacing deprecated declarations with their\n    suggested replacements\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1435%2FAtariDreams%2Fcurl-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1435/AtariDreams/curl-v3\nPull-Request: https://github.com/git/git/pull/1435\n\nRange-diff vs v2:\n\n 1:  c40fb2de13d ! 1:  14ca56fe608 curl: resolve deprecated curl declarations\n     @@ Commit message\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     + ## INSTALL ##\n     +@@ INSTALL: Issues of note:\n     + \t  not need that functionality, use NO_CURL to build without\n     + \t  it.\n     + \n     +-\t  Git requires version \"7.19.4\" or later of \"libcurl\" to build\n     ++\t  Git requires version \"7.19.5\" or later of \"libcurl\" to build\n     + \t  without NO_CURL. This version requirement may be bumped in\n     + \t  the future.\n     + \n     +\n       ## git-curl-compat.h ##\n      @@\n       #endif\n     @@ http-push.c: static void curl_setup_http(CURL *curl, const char *url,\n       \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n      -\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n      -\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);\n     -+\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, ioctl_buffer);\n     ++\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n      +\tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n       \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n       \tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n       \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n      \n       ## http.c ##\n     +@@ http.c: static const char *http_proxy_ssl_ca_info;\n     + static struct credential proxy_cert_auth = CREDENTIAL_INIT;\n     + static int proxy_ssl_cert_password_required;\n     + \n     ++#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     ++static char protocol_list[20];\n     ++#endif\n     ++\n     + static struct {\n     + \tconst char *name;\n     + \tlong curlauth_param;\n      @@ http.c: size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n       \treturn size / eltsize;\n       }\n       \n      -curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n     -+int ioctl_buffer(void *userp, curl_off_t offset, int origin)\n     ++int seek_buffer(void *userp, curl_off_t offset, int origin)\n       {\n      -\tstruct buffer *buffer = clientp;\n     -+\tstruct buffer *buffer = userp;\n     - \n     +-\n      -\tswitch (cmd) {\n      -\tcase CURLIOCMD_NOP:\n      -\t\treturn CURLIOE_OK;\n     @@ http.c: size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffe\n      -\tcase CURLIOCMD_RESTARTREAD:\n      -\t\tbuffer->posn = 0;\n      -\t\treturn CURLIOE_OK;\n     --\n     ++\tstruct buffer *buffer = userp;\n     + \n      -\tdefault:\n      -\t\treturn CURLIOE_UNKNOWNCMD;\n     --\t}\n     -+\tbuffer->posn = 0;\n     ++\tif (origin != SEEK_SET)\n     ++\t\tBUG(\"seek_buffer only handles SEEK_SET\");\n     ++\tif (offset < 0 || offset >= buffer->buf.len) {\n     ++\t\terror(\"curl seek would be outside of buffer\");\n     ++\t\treturn CURL_SEEKFUNC_FAIL;\n     + \t}\n     ++\n     ++\tbuffer->posn = offset;\n      +\treturn CURL_SEEKFUNC_OK;\n       }\n       \n     @@ http.c: void setup_curl_trace(CURL *handle)\n       \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n       }\n      +#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+static void get_curl_allowed_protocols(int from_user, char *protocol)\n     ++static void get_curl_allowed_protocols(int from_user)\n      +{\n      +\tunsigned int i = 0;\n     -+\n     + \n      +\tif (is_transport_allowed(\"http\", from_user)) {\n     -+\t\tprotocol[i++] = 'h';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 'p';\n     ++\t\tprotocol_list[i++] = 'h';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 'p';\n      +\t}\n      +\n      +\tif (is_transport_allowed(\"https\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol[i++] = ',';\n     ++\t\t\tprotocol_list[i++] = ',';\n      +\t\t}\n      +\n     -+\t\tprotocol[i++] = 'h';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 'p';\n     -+\t\tprotocol[i++] = 's';\n     ++\t\tprotocol_list[i++] = 'h';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 'p';\n     ++\t\tprotocol_list[i++] = 's';\n      +\t}\n      +\tif (is_transport_allowed(\"ftp\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol[i++] = ',';\n     ++\t\t\tprotocol_list[i++] = ',';\n      +\t\t}\n     - \n     -+\t\tprotocol[i++] = 'f';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 'p';\n     ++\n     ++\t\tprotocol_list[i++] = 'f';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 'p';\n      +\t}\n      +\tif (is_transport_allowed(\"ftps\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol[i++] = ',';\n     ++\t\t\tprotocol_list[i++] = ',';\n      +\t\t}\n      +\n     -+\t\tprotocol[i++] = 'f';\n     -+\t\tprotocol[i++] = 't';\n     -+\t\tprotocol[i++] = 'p';\n     -+\t\tprotocol[i++] = 's';\n     ++\t\tprotocol_list[i++] = 'f';\n     ++\t\tprotocol_list[i++] = 't';\n     ++\t\tprotocol_list[i++] = 'p';\n     ++\t\tprotocol_list[i++] = 's';\n      +\t}\n      +\n     -+\tprotocol[i] = '\\0';\n     ++\tprotocol_list[i] = '\\0';\n      +}\n      +#else\n       static long get_curl_allowed_protocols(int from_user)\n     @@ http.c: static long get_curl_allowed_protocols(int from_user)\n       \n       #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n       static int get_curl_http_version_opt(const char *version_string, long *opt)\n     -@@ http.c: static int get_curl_http_version_opt(const char *version_string, long *opt)\n     - static CURL *get_curl_handle(void)\n     - {\n     - \tCURL *result = curl_easy_init();\n     -+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+\tstatic char protocol[20], redir_protocol[20];\n     -+#endif\n     - \n     - \tif (!result)\n     - \t\tdie(\"curl_easy_init failed\");\n      @@ http.c: static CURL *get_curl_handle(void)\n       \n       \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n       \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n      +#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+\tget_curl_allowed_protocols(0, redir_protocol);\n     ++\tget_curl_allowed_protocols(0);\n      +\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n     -+\tget_curl_allowed_protocols(-1, protocol);\n     ++\tget_curl_allowed_protocols(-1);\n      +\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol);\n      +#else\n       \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n     @@ http.h: struct buffer {\n       size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n       size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n      -curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n     -+int ioctl_buffer(void *userp, curl_off_t offset, int origin);\n     ++int seek_buffer(void *userp, curl_off_t offset, int origin);\n       \n       /* Slot lifecycle functions */\n       struct active_request_slot *get_active_slot(void);\n     @@ remote-curl.c: static size_t rpc_out(void *ptr, size_t eltsize,\n       }\n       \n      -static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n     -+static int rpc_ioctl(void *userp, curl_off_t offset, int origin)\n     ++static int rpc_seek(void *userp, curl_off_t offset, int origin)\n       {\n      -\tstruct rpc_state *rpc = clientp;\n      +\tstruct rpc_state *rpc = userp;\n     @@ remote-curl.c: static size_t rpc_out(void *ptr, size_t eltsize,\n      -\tswitch (cmd) {\n      -\tcase CURLIOCMD_NOP:\n      -\t\treturn CURLIOE_OK;\n     --\n     ++\tif (origin != SEEK_SET)\n     ++\t\tBUG(\"rpc_seek only handles SEEK_SET, not %d\", origin);\n     + \n      -\tcase CURLIOCMD_RESTARTREAD:\n      -\t\tif (rpc->initial_buffer) {\n      -\t\t\trpc->pos = 0;\n      -\t\t\treturn CURLIOE_OK;\n     --\t\t}\n     ++\tif (rpc->initial_buffer) {\n     ++\t\tif (offset < 0 || offset > rpc->len) {\n     ++\t\t\terror(\"curl seek would be outside of rpc buffer\");\n     ++\t\t\treturn CURL_SEEKFUNC_FAIL;\n     + \t\t}\n      -\t\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n      -\t\treturn CURLIOE_FAILRESTART;\n      -\n      -\tdefault:\n      -\t\treturn CURLIOE_UNKNOWNCMD;\n     -+\tif (rpc->initial_buffer) {\n     -+\t\trpc->pos = 0;\n     ++\t\trpc->pos = offset;\n      +\t\treturn CURL_SEEKFUNC_OK;\n       \t}\n      +\n     @@ remote-curl.c: retry:\n       \t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_ioctl);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_seek);\n      +\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);\n       \t\tif (options.verbosity > 1) {\n       \t\t\tfprintf(stderr, \"POST %s (chunked)\\n\", rpc->service_name);\n\n\n INSTALL           |  2 +-\n git-curl-compat.h |  8 +++++\n http-push.c       |  6 ++--\n http.c            | 80 ++++++++++++++++++++++++++++++++++++++++-------\n http.h            |  2 +-\n remote-curl.c     | 31 +++++++++---------\n 6 files changed, 96 insertions(+), 33 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 33447883974..d5694f8c470 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -139,7 +139,7 @@ Issues of note:\n \t  not need that functionality, use NO_CURL to build without\n \t  it.\n \n-\t  Git requires version \"7.19.4\" or later of \"libcurl\" to build\n+\t  Git requires version \"7.19.5\" or later of \"libcurl\" to build\n \t  without NO_CURL. This version requirement may be bumped in\n \t  the future.\n \ndiff --git a/git-curl-compat.h b/git-curl-compat.h\nindex 56a83b6bbd8..38a2237c8fe 100644\n--- a/git-curl-compat.h\n+++ b/git-curl-compat.h\n@@ -127,3 +127,11 @@\n #endif\n \n #endif\n+\n+/**\n+ * CURLOPT_PROTOCOLS_STR was added in 7.83.0, released in August\n+ * 2022.\n+ */\n+#if LIBCURL_VERSION_NUM >= 0x075500\n+#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1\n+#endif\ndiff --git a/http-push.c b/http-push.c\nindex 5f4340a36e6..7f71316456c 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -198,13 +198,13 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n \tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\ndiff --git a/http.c b/http.c\nindex 8a5ba3f4776..671bfd834f3 100644\n--- a/http.c\n+++ b/http.c\n@@ -76,6 +76,10 @@ static const char *http_proxy_ssl_ca_info;\n static struct credential proxy_cert_auth = CREDENTIAL_INIT;\n static int proxy_ssl_cert_password_required;\n \n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+static char protocol_list[20];\n+#endif\n+\n static struct {\n \tconst char *name;\n \tlong curlauth_param;\n@@ -157,21 +161,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n \treturn size / eltsize;\n }\n \n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n+int seek_buffer(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct buffer *buffer = clientp;\n-\n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tbuffer->posn = 0;\n-\t\treturn CURLIOE_OK;\n+\tstruct buffer *buffer = userp;\n \n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\tif (origin != SEEK_SET)\n+\t\tBUG(\"seek_buffer only handles SEEK_SET\");\n+\tif (offset < 0 || offset >= buffer->buf.len) {\n+\t\terror(\"curl seek would be outside of buffer\");\n+\t\treturn CURL_SEEKFUNC_FAIL;\n \t}\n+\n+\tbuffer->posn = offset;\n+\treturn CURL_SEEKFUNC_OK;\n }\n \n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n@@ -765,7 +767,52 @@ void setup_curl_trace(CURL *handle)\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n }\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+static void get_curl_allowed_protocols(int from_user)\n+{\n+\tunsigned int i = 0;\n \n+\tif (is_transport_allowed(\"http\", from_user)) {\n+\t\tprotocol_list[i++] = 'h';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 'p';\n+\t}\n+\n+\tif (is_transport_allowed(\"https\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_list[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_list[i++] = 'h';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 'p';\n+\t\tprotocol_list[i++] = 's';\n+\t}\n+\tif (is_transport_allowed(\"ftp\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_list[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_list[i++] = 'f';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 'p';\n+\t}\n+\tif (is_transport_allowed(\"ftps\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_list[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_list[i++] = 'f';\n+\t\tprotocol_list[i++] = 't';\n+\t\tprotocol_list[i++] = 'p';\n+\t\tprotocol_list[i++] = 's';\n+\t}\n+\n+\tprotocol_list[i] = '\\0';\n+}\n+#else\n static long get_curl_allowed_protocols(int from_user)\n {\n \tlong allowed_protocols = 0;\n@@ -781,6 +828,7 @@ static long get_curl_allowed_protocols(int from_user)\n \n \treturn allowed_protocols;\n }\n+#endif\n \n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n@@ -923,10 +971,18 @@ static CURL *get_curl_handle(void)\n \n \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+\tget_curl_allowed_protocols(0);\n+\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n+\tget_curl_allowed_protocols(-1);\n+\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol);\n+#else\n \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(0));\n \tcurl_easy_setopt(result, CURLOPT_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(-1));\n+#endif\n+\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\thttp_trace_curl_no_data();\n \tsetup_curl_trace(result);\ndiff --git a/http.h b/http.h\nindex 3c94c479100..0be9400ef53 100644\n--- a/http.h\n+++ b/http.h\n@@ -40,7 +40,7 @@ struct buffer {\n size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n+int seek_buffer(void *userp, curl_off_t offset, int origin);\n \n /* Slot lifecycle functions */\n struct active_request_slot *get_active_slot(void);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 72dfb8fb86a..540da2b7989 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -717,25 +717,24 @@ static size_t rpc_out(void *ptr, size_t eltsize,\n \treturn avail;\n }\n \n-static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n+static int rpc_seek(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct rpc_state *rpc = clientp;\n+\tstruct rpc_state *rpc = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n+\tif (origin != SEEK_SET)\n+\t\tBUG(\"rpc_seek only handles SEEK_SET, not %d\", origin);\n \n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tif (rpc->initial_buffer) {\n-\t\t\trpc->pos = 0;\n-\t\t\treturn CURLIOE_OK;\n+\tif (rpc->initial_buffer) {\n+\t\tif (offset < 0 || offset > rpc->len) {\n+\t\t\terror(\"curl seek would be outside of rpc buffer\");\n+\t\t\treturn CURL_SEEKFUNC_FAIL;\n \t\t}\n-\t\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n-\t\treturn CURLIOE_FAILRESTART;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\t\trpc->pos = offset;\n+\t\treturn CURL_SEEKFUNC_OK;\n \t}\n+\n+\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n+\treturn CURL_SEEKFUNC_FAIL;\n }\n \n struct check_pktline_state {\n@@ -959,8 +958,8 @@ retry:\n \t\trpc->initial_buffer = 1;\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_seek);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);\n \t\tif (options.verbosity > 1) {\n \t\t\tfprintf(stderr, \"POST %s (chunked)\\n\", rpc->service_name);\n \t\t\tfflush(stderr);\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"},{"id":"470542","messageId":"pull.1435.v4.git.git.1673986152672.gitgitgadget@gmail.com","threadId":"59106","inReplyTo":"pull.1435.v3.git.git.1673985725868.gitgitgadget@gmail.com","subject":"[PATCH v4] curl: resolve deprecated curl declarations","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-17T20:09:12Z","receivedAt":"2023-01-17T21:48:16Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFix CI-Alpine build by replacing deprecated\ndeclarations with their suggested replacements\n\nNote that this required changing the\ncallbacks of functions because the replacement\nfor these deprecations require a different function\nsignature for the callback and different parameters.\n\nEvery change done was made as to minimize\nchanged behavior as well as get the CI to pass again.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    curl: resolve deprecated curl declarations\n    \n    Fix CI-Alpine build by replacing deprecated declarations with their\n    suggested replacements\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1435%2FAtariDreams%2Fcurl-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1435/AtariDreams/curl-v4\nPull-Request: https://github.com/git/git/pull/1435\n\nRange-diff vs v3:\n\n 1:  14ca56fe608 ! 1:  ebe36ad23fa curl: resolve deprecated curl declarations\n     @@ http-push.c: static void curl_setup_http(CURL *curl, const char *url,\n       \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n      \n       ## http.c ##\n     -@@ http.c: static const char *http_proxy_ssl_ca_info;\n     - static struct credential proxy_cert_auth = CREDENTIAL_INIT;\n     - static int proxy_ssl_cert_password_required;\n     - \n     -+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+static char protocol_list[20];\n     -+#endif\n     -+\n     - static struct {\n     - \tconst char *name;\n     - \tlong curlauth_param;\n      @@ http.c: size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n       \treturn size / eltsize;\n       }\n     @@ http.c: size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffe\n      +int seek_buffer(void *userp, curl_off_t offset, int origin)\n       {\n      -\tstruct buffer *buffer = clientp;\n     --\n     ++\tstruct buffer *buffer = userp;\n     + \n      -\tswitch (cmd) {\n      -\tcase CURLIOCMD_NOP:\n      -\t\treturn CURLIOE_OK;\n     @@ http.c: size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffe\n      -\tcase CURLIOCMD_RESTARTREAD:\n      -\t\tbuffer->posn = 0;\n      -\t\treturn CURLIOE_OK;\n     -+\tstruct buffer *buffer = userp;\n     - \n     +-\n      -\tdefault:\n      -\t\treturn CURLIOE_UNKNOWNCMD;\n      +\tif (origin != SEEK_SET)\n     @@ http.c: void setup_curl_trace(CURL *handle)\n       \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n       }\n      +#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+static void get_curl_allowed_protocols(int from_user)\n     ++static void get_curl_allowed_protocols(char* protocol_buff, int from_user)\n      +{\n      +\tunsigned int i = 0;\n     - \n     ++\n      +\tif (is_transport_allowed(\"http\", from_user)) {\n     -+\t\tprotocol_list[i++] = 'h';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 'p';\n     ++\t\tprotocol_buff[i++] = 'h';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 'p';\n      +\t}\n      +\n      +\tif (is_transport_allowed(\"https\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol_list[i++] = ',';\n     ++\t\t\tprotocol_buff[i++] = ',';\n      +\t\t}\n      +\n     -+\t\tprotocol_list[i++] = 'h';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 'p';\n     -+\t\tprotocol_list[i++] = 's';\n     ++\t\tprotocol_buff[i++] = 'h';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 'p';\n     ++\t\tprotocol_buff[i++] = 's';\n      +\t}\n      +\tif (is_transport_allowed(\"ftp\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol_list[i++] = ',';\n     ++\t\t\tprotocol_buff[i++] = ',';\n      +\t\t}\n      +\n     -+\t\tprotocol_list[i++] = 'f';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 'p';\n     ++\t\tprotocol_buff[i++] = 'f';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 'p';\n      +\t}\n      +\tif (is_transport_allowed(\"ftps\", from_user)) {\n      +\t\tif (i != 0) {\n     -+\t\t\tprotocol_list[i++] = ',';\n     ++\t\t\tprotocol_buff[i++] = ',';\n      +\t\t}\n      +\n     -+\t\tprotocol_list[i++] = 'f';\n     -+\t\tprotocol_list[i++] = 't';\n     -+\t\tprotocol_list[i++] = 'p';\n     -+\t\tprotocol_list[i++] = 's';\n     ++\t\tprotocol_buff[i++] = 'f';\n     ++\t\tprotocol_buff[i++] = 't';\n     ++\t\tprotocol_buff[i++] = 'p';\n     ++\t\tprotocol_buff[i++] = 's';\n      +\t}\n     -+\n     -+\tprotocol_list[i] = '\\0';\n     + \n     ++\tprotocol_buff[i] = '\\0';\n      +}\n      +#else\n       static long get_curl_allowed_protocols(int from_user)\n     @@ http.c: static long get_curl_allowed_protocols(int from_user)\n       \n       #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n       static int get_curl_http_version_opt(const char *version_string, long *opt)\n     +@@ http.c: static int get_curl_http_version_opt(const char *version_string, long *opt)\n     + \n     + static CURL *get_curl_handle(void)\n     + {\n     ++\n     ++#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     ++char protocol_buff[20];\n     ++#endif\n     ++\n     + \tCURL *result = curl_easy_init();\n     + \n     + \tif (!result)\n      @@ http.c: static CURL *get_curl_handle(void)\n       \n       \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n       \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n      +#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     -+\tget_curl_allowed_protocols(0);\n     -+\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, redir_protocol);\n     -+\tget_curl_allowed_protocols(-1);\n     -+\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol);\n     ++\tget_curl_allowed_protocols(protocol_buff, 0);\n     ++\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, protocol_buff);\n     ++\tget_curl_allowed_protocols(protocol_buff, -1);\n     ++\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol_buff);\n      +#else\n       \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n       \t\t\t get_curl_allowed_protocols(0));\n\n\n INSTALL           |  2 +-\n git-curl-compat.h |  8 +++++\n http-push.c       |  6 ++--\n http.c            | 81 ++++++++++++++++++++++++++++++++++++++++-------\n http.h            |  2 +-\n remote-curl.c     | 31 +++++++++---------\n 6 files changed, 97 insertions(+), 33 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 33447883974..d5694f8c470 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -139,7 +139,7 @@ Issues of note:\n \t  not need that functionality, use NO_CURL to build without\n \t  it.\n \n-\t  Git requires version \"7.19.4\" or later of \"libcurl\" to build\n+\t  Git requires version \"7.19.5\" or later of \"libcurl\" to build\n \t  without NO_CURL. This version requirement may be bumped in\n \t  the future.\n \ndiff --git a/git-curl-compat.h b/git-curl-compat.h\nindex 56a83b6bbd8..38a2237c8fe 100644\n--- a/git-curl-compat.h\n+++ b/git-curl-compat.h\n@@ -127,3 +127,11 @@\n #endif\n \n #endif\n+\n+/**\n+ * CURLOPT_PROTOCOLS_STR was added in 7.83.0, released in August\n+ * 2022.\n+ */\n+#if LIBCURL_VERSION_NUM >= 0x075500\n+#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1\n+#endif\ndiff --git a/http-push.c b/http-push.c\nindex 5f4340a36e6..7f71316456c 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -198,13 +198,13 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n \tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\ndiff --git a/http.c b/http.c\nindex 8a5ba3f4776..e51a9a61a20 100644\n--- a/http.c\n+++ b/http.c\n@@ -157,21 +157,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n \treturn size / eltsize;\n }\n \n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n+int seek_buffer(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct buffer *buffer = clientp;\n+\tstruct buffer *buffer = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n-\n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tbuffer->posn = 0;\n-\t\treturn CURLIOE_OK;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\tif (origin != SEEK_SET)\n+\t\tBUG(\"seek_buffer only handles SEEK_SET\");\n+\tif (offset < 0 || offset >= buffer->buf.len) {\n+\t\terror(\"curl seek would be outside of buffer\");\n+\t\treturn CURL_SEEKFUNC_FAIL;\n \t}\n+\n+\tbuffer->posn = offset;\n+\treturn CURL_SEEKFUNC_OK;\n }\n \n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n@@ -765,7 +763,52 @@ void setup_curl_trace(CURL *handle)\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);\n \tcurl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);\n }\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+static void get_curl_allowed_protocols(char* protocol_buff, int from_user)\n+{\n+\tunsigned int i = 0;\n+\n+\tif (is_transport_allowed(\"http\", from_user)) {\n+\t\tprotocol_buff[i++] = 'h';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 'p';\n+\t}\n+\n+\tif (is_transport_allowed(\"https\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_buff[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_buff[i++] = 'h';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 'p';\n+\t\tprotocol_buff[i++] = 's';\n+\t}\n+\tif (is_transport_allowed(\"ftp\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_buff[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_buff[i++] = 'f';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 'p';\n+\t}\n+\tif (is_transport_allowed(\"ftps\", from_user)) {\n+\t\tif (i != 0) {\n+\t\t\tprotocol_buff[i++] = ',';\n+\t\t}\n+\n+\t\tprotocol_buff[i++] = 'f';\n+\t\tprotocol_buff[i++] = 't';\n+\t\tprotocol_buff[i++] = 'p';\n+\t\tprotocol_buff[i++] = 's';\n+\t}\n \n+\tprotocol_buff[i] = '\\0';\n+}\n+#else\n static long get_curl_allowed_protocols(int from_user)\n {\n \tlong allowed_protocols = 0;\n@@ -781,6 +824,7 @@ static long get_curl_allowed_protocols(int from_user)\n \n \treturn allowed_protocols;\n }\n+#endif\n \n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n@@ -809,6 +853,11 @@ static int get_curl_http_version_opt(const char *version_string, long *opt)\n \n static CURL *get_curl_handle(void)\n {\n+\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+char protocol_buff[20];\n+#endif\n+\n \tCURL *result = curl_easy_init();\n \n \tif (!result)\n@@ -923,10 +972,18 @@ static CURL *get_curl_handle(void)\n \n \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n+\tget_curl_allowed_protocols(protocol_buff, 0);\n+\tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, protocol_buff);\n+\tget_curl_allowed_protocols(protocol_buff, -1);\n+\tcurl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, protocol_buff);\n+#else\n \tcurl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(0));\n \tcurl_easy_setopt(result, CURLOPT_PROTOCOLS,\n \t\t\t get_curl_allowed_protocols(-1));\n+#endif\n+\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\thttp_trace_curl_no_data();\n \tsetup_curl_trace(result);\ndiff --git a/http.h b/http.h\nindex 3c94c479100..0be9400ef53 100644\n--- a/http.h\n+++ b/http.h\n@@ -40,7 +40,7 @@ struct buffer {\n size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n+int seek_buffer(void *userp, curl_off_t offset, int origin);\n \n /* Slot lifecycle functions */\n struct active_request_slot *get_active_slot(void);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 72dfb8fb86a..540da2b7989 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -717,25 +717,24 @@ static size_t rpc_out(void *ptr, size_t eltsize,\n \treturn avail;\n }\n \n-static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n+static int rpc_seek(void *userp, curl_off_t offset, int origin)\n {\n-\tstruct rpc_state *rpc = clientp;\n+\tstruct rpc_state *rpc = userp;\n \n-\tswitch (cmd) {\n-\tcase CURLIOCMD_NOP:\n-\t\treturn CURLIOE_OK;\n+\tif (origin != SEEK_SET)\n+\t\tBUG(\"rpc_seek only handles SEEK_SET, not %d\", origin);\n \n-\tcase CURLIOCMD_RESTARTREAD:\n-\t\tif (rpc->initial_buffer) {\n-\t\t\trpc->pos = 0;\n-\t\t\treturn CURLIOE_OK;\n+\tif (rpc->initial_buffer) {\n+\t\tif (offset < 0 || offset > rpc->len) {\n+\t\t\terror(\"curl seek would be outside of rpc buffer\");\n+\t\t\treturn CURL_SEEKFUNC_FAIL;\n \t\t}\n-\t\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n-\t\treturn CURLIOE_FAILRESTART;\n-\n-\tdefault:\n-\t\treturn CURLIOE_UNKNOWNCMD;\n+\t\trpc->pos = offset;\n+\t\treturn CURL_SEEKFUNC_OK;\n \t}\n+\n+\terror(_(\"unable to rewind rpc post data - try increasing http.postBuffer\"));\n+\treturn CURL_SEEKFUNC_FAIL;\n }\n \n struct check_pktline_state {\n@@ -959,8 +958,8 @@ retry:\n \t\trpc->initial_buffer = 1;\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_seek);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);\n \t\tif (options.verbosity > 1) {\n \t\t\tfprintf(stderr, \"POST %s (chunked)\\n\", rpc->service_name);\n \t\t\tfflush(stderr);\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"}]}