@@ -165,21 +165,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
165165 return size / eltsize ;
166166}
167167
168- curlioerr ioctl_buffer ( CURL * handle , int cmd , void * clientp )
168+ int seek_buffer ( void * clientp , curl_off_t offset , int origin )
169169{
170170 struct buffer * buffer = clientp ;
171171
172- switch (cmd ) {
173- case CURLIOCMD_NOP :
174- return CURLIOE_OK ;
175-
176- case CURLIOCMD_RESTARTREAD :
177- buffer -> posn = 0 ;
178- return CURLIOE_OK ;
179-
180- default :
181- return CURLIOE_UNKNOWNCMD ;
172+ if (origin != SEEK_SET )
173+ BUG ("seek_buffer only handles SEEK_SET" );
174+ if (offset < 0 || offset >= buffer -> buf .len ) {
175+ error ("curl seek would be outside of buffer" );
176+ return CURL_SEEKFUNC_FAIL ;
182177 }
178+
179+ buffer -> posn = offset ;
180+ return CURL_SEEKFUNC_OK ;
183181}
184182
185183size_t fwrite_buffer (char * ptr , size_t eltsize , size_t nmemb , void * buffer_ )
@@ -791,20 +789,37 @@ void setup_curl_trace(CURL *handle)
791789 curl_easy_setopt (handle , CURLOPT_DEBUGDATA , NULL );
792790}
793791
794- static long get_curl_allowed_protocols ( int from_user )
792+ static void proto_list_append ( struct strbuf * list , const char * proto )
795793{
796- long allowed_protocols = 0 ;
794+ if (!list )
795+ return ;
796+ if (list -> len )
797+ strbuf_addch (list , ',' );
798+ strbuf_addstr (list , proto );
799+ }
797800
798- if (is_transport_allowed ("http" , from_user ))
799- allowed_protocols |= CURLPROTO_HTTP ;
800- if (is_transport_allowed ("https" , from_user ))
801- allowed_protocols |= CURLPROTO_HTTPS ;
802- if (is_transport_allowed ("ftp" , from_user ))
803- allowed_protocols |= CURLPROTO_FTP ;
804- if (is_transport_allowed ("ftps" , from_user ))
805- allowed_protocols |= CURLPROTO_FTPS ;
801+ static long get_curl_allowed_protocols (int from_user , struct strbuf * list )
802+ {
803+ long bits = 0 ;
806804
807- return allowed_protocols ;
805+ if (is_transport_allowed ("http" , from_user )) {
806+ bits |= CURLPROTO_HTTP ;
807+ proto_list_append (list , "http" );
808+ }
809+ if (is_transport_allowed ("https" , from_user )) {
810+ bits |= CURLPROTO_HTTPS ;
811+ proto_list_append (list , "https" );
812+ }
813+ if (is_transport_allowed ("ftp" , from_user )) {
814+ bits |= CURLPROTO_FTP ;
815+ proto_list_append (list , "ftp" );
816+ }
817+ if (is_transport_allowed ("ftps" , from_user )) {
818+ bits |= CURLPROTO_FTPS ;
819+ proto_list_append (list , "ftps" );
820+ }
821+
822+ return bits ;
808823}
809824
810825#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
@@ -959,10 +974,26 @@ static CURL *get_curl_handle(void)
959974
960975 curl_easy_setopt (result , CURLOPT_MAXREDIRS , 20 );
961976 curl_easy_setopt (result , CURLOPT_POSTREDIR , CURL_REDIR_POST_ALL );
977+
978+ #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR
979+ {
980+ struct strbuf buf = STRBUF_INIT ;
981+
982+ get_curl_allowed_protocols (0 , & buf );
983+ curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS_STR , buf .buf );
984+ strbuf_reset (& buf );
985+
986+ get_curl_allowed_protocols (-1 , & buf );
987+ curl_easy_setopt (result , CURLOPT_PROTOCOLS_STR , buf .buf );
988+ strbuf_release (& buf );
989+ }
990+ #else
962991 curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS ,
963- get_curl_allowed_protocols (0 ));
992+ get_curl_allowed_protocols (0 , NULL ));
964993 curl_easy_setopt (result , CURLOPT_PROTOCOLS ,
965- get_curl_allowed_protocols (-1 ));
994+ get_curl_allowed_protocols (-1 , NULL ));
995+ #endif
996+
966997 if (getenv ("GIT_CURL_VERBOSE" ))
967998 http_trace_curl_no_data ();
968999 setup_curl_trace (result );
0 commit comments