@@ -155,21 +155,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
155155 return size / eltsize ;
156156}
157157
158- curlioerr ioctl_buffer ( CURL * handle , int cmd , void * clientp )
158+ int seek_buffer ( void * clientp , curl_off_t offset , int origin )
159159{
160160 struct buffer * buffer = clientp ;
161161
162- switch (cmd ) {
163- case CURLIOCMD_NOP :
164- return CURLIOE_OK ;
165-
166- case CURLIOCMD_RESTARTREAD :
167- buffer -> posn = 0 ;
168- return CURLIOE_OK ;
169-
170- default :
171- return CURLIOE_UNKNOWNCMD ;
162+ if (origin != SEEK_SET )
163+ BUG ("seek_buffer only handles SEEK_SET" );
164+ if (offset < 0 || offset >= buffer -> buf .len ) {
165+ error ("curl seek would be outside of buffer" );
166+ return CURL_SEEKFUNC_FAIL ;
172167 }
168+
169+ buffer -> posn = offset ;
170+ return CURL_SEEKFUNC_OK ;
173171}
174172
175173size_t fwrite_buffer (char * ptr , size_t eltsize , size_t nmemb , void * buffer_ )
@@ -717,20 +715,37 @@ void setup_curl_trace(CURL *handle)
717715 curl_easy_setopt (handle , CURLOPT_DEBUGDATA , NULL );
718716}
719717
720- static long get_curl_allowed_protocols ( int from_user )
718+ static void proto_list_append ( struct strbuf * list , const char * proto )
721719{
722- long allowed_protocols = 0 ;
720+ if (!list )
721+ return ;
722+ if (list -> len )
723+ strbuf_addch (list , ',' );
724+ strbuf_addstr (list , proto );
725+ }
723726
724- if (is_transport_allowed ("http" , from_user ))
725- allowed_protocols |= CURLPROTO_HTTP ;
726- if (is_transport_allowed ("https" , from_user ))
727- allowed_protocols |= CURLPROTO_HTTPS ;
728- if (is_transport_allowed ("ftp" , from_user ))
729- allowed_protocols |= CURLPROTO_FTP ;
730- if (is_transport_allowed ("ftps" , from_user ))
731- allowed_protocols |= CURLPROTO_FTPS ;
727+ static long get_curl_allowed_protocols (int from_user , struct strbuf * list )
728+ {
729+ long bits = 0 ;
732730
733- return allowed_protocols ;
731+ if (is_transport_allowed ("http" , from_user )) {
732+ bits |= CURLPROTO_HTTP ;
733+ proto_list_append (list , "http" );
734+ }
735+ if (is_transport_allowed ("https" , from_user )) {
736+ bits |= CURLPROTO_HTTPS ;
737+ proto_list_append (list , "https" );
738+ }
739+ if (is_transport_allowed ("ftp" , from_user )) {
740+ bits |= CURLPROTO_FTP ;
741+ proto_list_append (list , "ftp" );
742+ }
743+ if (is_transport_allowed ("ftps" , from_user )) {
744+ bits |= CURLPROTO_FTPS ;
745+ proto_list_append (list , "ftps" );
746+ }
747+
748+ return bits ;
734749}
735750
736751#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
@@ -874,10 +889,26 @@ static CURL *get_curl_handle(void)
874889
875890 curl_easy_setopt (result , CURLOPT_MAXREDIRS , 20 );
876891 curl_easy_setopt (result , CURLOPT_POSTREDIR , CURL_REDIR_POST_ALL );
892+
893+ #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR
894+ {
895+ struct strbuf buf = STRBUF_INIT ;
896+
897+ get_curl_allowed_protocols (0 , & buf );
898+ curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS_STR , buf .buf );
899+ strbuf_reset (& buf );
900+
901+ get_curl_allowed_protocols (-1 , & buf );
902+ curl_easy_setopt (result , CURLOPT_PROTOCOLS_STR , buf .buf );
903+ strbuf_release (& buf );
904+ }
905+ #else
877906 curl_easy_setopt (result , CURLOPT_REDIR_PROTOCOLS ,
878- get_curl_allowed_protocols (0 ));
907+ get_curl_allowed_protocols (0 , NULL ));
879908 curl_easy_setopt (result , CURLOPT_PROTOCOLS ,
880- get_curl_allowed_protocols (-1 ));
909+ get_curl_allowed_protocols (-1 , NULL ));
910+ #endif
911+
881912 if (getenv ("GIT_CURL_VERBOSE" ))
882913 http_trace_curl_no_data ();
883914 setup_curl_trace (result );
0 commit comments