@@ -157,21 +157,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
157157 return size / eltsize ;
158158}
159159
160- curlioerr ioctl_buffer ( CURL * handle , int cmd , void * clientp )
160+ int seek_buffer ( void * clientp , curl_off_t offset , int origin )
161161{
162162 struct buffer * buffer = clientp ;
163163
164- switch (cmd ) {
165- case CURLIOCMD_NOP :
166- return CURLIOE_OK ;
167-
168- case CURLIOCMD_RESTARTREAD :
169- buffer -> posn = 0 ;
170- return CURLIOE_OK ;
171-
172- default :
173- return CURLIOE_UNKNOWNCMD ;
164+ if (origin != SEEK_SET )
165+ BUG ("seek_buffer only handles SEEK_SET" );
166+ if (offset < 0 || offset >= buffer -> buf .len ) {
167+ error ("curl seek would be outside of buffer" );
168+ return CURL_SEEKFUNC_FAIL ;
174169 }
170+
171+ buffer -> posn = offset ;
172+ return CURL_SEEKFUNC_OK ;
175173}
176174
177175size_t fwrite_buffer (char * ptr , size_t eltsize , size_t nmemb , void * buffer_ )
@@ -766,20 +764,37 @@ void setup_curl_trace(CURL *handle)
766764 curl_easy_setopt (handle , CURLOPT_DEBUGDATA , NULL );
767765}
768766
769- static long get_curl_allowed_protocols ( int from_user )
767+ static void proto_list_append ( struct strbuf * list , const char * proto )
770768{
771- long allowed_protocols = 0 ;
769+ if (!list )
770+ return ;
771+ if (list -> len )
772+ strbuf_addch (list , ',' );
773+ strbuf_addstr (list , proto );
774+ }
772775
773- if (is_transport_allowed ("http" , from_user ))
774- allowed_protocols |= CURLPROTO_HTTP ;
775- if (is_transport_allowed ("https" , from_user ))
776- allowed_protocols |= CURLPROTO_HTTPS ;
777- if (is_transport_allowed ("ftp" , from_user ))
778- allowed_protocols |= CURLPROTO_FTP ;
779- if (is_transport_allowed ("ftps" , from_user ))
780- allowed_protocols |= CURLPROTO_FTPS ;
776+ static long get_curl_allowed_protocols (int from_user , struct strbuf * list )
777+ {
778+ long bits = 0 ;
781779
782- return allowed_protocols ;
780+ if (is_transport_allowed ("http" , from_user )) {
781+ bits |= CURLPROTO_HTTP ;
782+ proto_list_append (list , "http" );
783+ }
784+ if (is_transport_allowed ("https" , from_user )) {
785+ bits |= CURLPROTO_HTTPS ;
786+ proto_list_append (list , "https" );
787+ }
788+ if (is_transport_allowed ("ftp" , from_user )) {
789+ bits |= CURLPROTO_FTP ;
790+ proto_list_append (list , "ftp" );
791+ }
792+ if (is_transport_allowed ("ftps" , from_user )) {
793+ bits |= CURLPROTO_FTPS ;
794+ proto_list_append (list , "ftps" );
795+ }
796+
797+ return bits ;
783798}
784799
785800#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
@@ -923,10 +938,26 @@ static CURL *get_curl_handle(void)
923938
924939 curl_easy_setopt (result , CURLOPT_MAXREDIRS , 20 );
925940 curl_easy_setopt (result , CURLOPT_POSTREDIR , CURL_REDIR_POST_ALL );
941+
942+ #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR
943+ {
944+ struct strbuf buf = STRBUF_INIT ;
945+
946+ get_curl_allowed_protocols (0 , & buf );
947+ curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS_STR , buf .buf );
948+ strbuf_reset (& buf );
949+
950+ get_curl_allowed_protocols (-1 , & buf );
951+ curl_easy_setopt (result , CURLOPT_PROTOCOLS_STR , buf .buf );
952+ strbuf_release (& buf );
953+ }
954+ #else
926955 curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS ,
927- get_curl_allowed_protocols (0 ));
956+ get_curl_allowed_protocols (0 , NULL ));
928957 curl_easy_setopt (result , CURLOPT_PROTOCOLS ,
929- get_curl_allowed_protocols (-1 ));
958+ get_curl_allowed_protocols (-1 , NULL ));
959+ #endif
960+
930961 if (getenv ("GIT_CURL_VERBOSE" ))
931962 http_trace_curl_no_data ();
932963 setup_curl_trace (result );
0 commit comments