File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -562,18 +562,23 @@ static int winhttp_stream_connect(winhttp_stream *s)
562562
563563 for (i = 0 ; i < t -> owner -> connect_opts .custom_headers .count ; i ++ ) {
564564 if (t -> owner -> connect_opts .custom_headers .strings [i ]) {
565+ wchar_t * custom_header_wide = NULL ;
566+
565567 git_str_clear (& buf );
566568 git_str_puts (& buf , t -> owner -> connect_opts .custom_headers .strings [i ]);
567- if (git__utf8_to_16 (ct , MAX_CONTENT_TYPE_LEN , git_str_cstr (& buf )) < 0 ) {
568- git_error_set (GIT_ERROR_OS , "failed to convert custom header to wide characters" );
569+
570+ /* Convert header to wide characters */
571+ if ((error = git__utf8_to_16_alloc (& custom_header_wide , git_str_cstr (& buf ))) < 0 )
569572 goto on_error ;
570- }
571573
572- if (!WinHttpAddRequestHeaders (s -> request , ct , (ULONG )- 1L ,
574+ if (!WinHttpAddRequestHeaders (s -> request , custom_header_wide , (ULONG )- 1L ,
573575 WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE )) {
574576 git_error_set (GIT_ERROR_OS , "failed to add a header to the request" );
577+ git__free (custom_header_wide );
575578 goto on_error ;
576579 }
580+
581+ git__free (custom_header_wide );
577582 }
578583 }
579584
Original file line number Diff line number Diff line change @@ -309,6 +309,16 @@ void test_online_clone__custom_headers(void)
309309 cl_git_pass (git_clone (& g_repo , LIVE_REPO_URL , "./foo" , & g_options ));
310310}
311311
312+ void test_online_clone__long_custom_header (void )
313+ {
314+ /* Long custom header with 1500 characters */
315+ char * ok = "X-Custom: a0MsqH2bXV9lILn7zkAHqKpGrOVvkik7SfoyqfXbFTxccsymN5SG9hEB0RLD9koTXKWtaI1vI9jHf5ViwLHq6xvkveFX9GiqaIhe3TRu5KDZrOBgeufdBYsTTONALPlpni9XVq71bR6x3AlVEqHdXi9qiq0TRuNiujMy0ZKs8LQ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MASrXBiBE1tibHLSTtK4UrodFNVhymtBCRnJdVRSgrCQcr2B5Jzs4Iv6uJlJqwwyuq6In54zcmecgJZezta84B3eFoSGJhCbI6Zza0khulccglCcppciWDStAHFhncePsCQL4tup0Z8fS01RksRQ7X1xgskVvQAKELThDqbJB4FJZwrwPXOpCweAoSONntp7Ly0lAUabw75gK5sR387IxNVdISmfP" ;
316+
317+ g_options .fetch_opts .custom_headers .count = 1 ;
318+ g_options .fetch_opts .custom_headers .strings = & ok ;
319+ cl_git_pass (git_clone (& g_repo , LIVE_REPO_URL , "./foo" , & g_options ));
320+ }
321+
312322static int cred_failure_cb (
313323 git_credential * * cred ,
314324 const char * url ,
You can’t perform that action at this time.
0 commit comments