summaryrefslogtreecommitdiff
path: root/src/libgit2
diff options
context:
space:
mode:
authorKevin Saul <kevinsaul@gmail.com>2022-07-22 15:18:03 +1200
committerKevin Saul <kevinsaul@gmail.com>2022-07-22 15:18:03 +1200
commitf5670326ffc7bd27e61b676df60f788c8f7106f1 (patch)
treee582afc68bee909c868980d908819260cec7965b /src/libgit2
parente85ef778691c44cc3a56fb83c9ea823620c1b4d0 (diff)
downloadlibgit2-f5670326ffc7bd27e61b676df60f788c8f7106f1.tar.gz
winhttp: handle long custom headers
Diffstat (limited to 'src/libgit2')
-rw-r--r--src/libgit2/transports/winhttp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libgit2/transports/winhttp.c b/src/libgit2/transports/winhttp.c
index 8ec5b37c5..098227607 100644
--- a/src/libgit2/transports/winhttp.c
+++ b/src/libgit2/transports/winhttp.c
@@ -562,18 +562,23 @@ static int winhttp_stream_connect(winhttp_stream *s)
for (i = 0; i < t->owner->connect_opts.custom_headers.count; i++) {
if (t->owner->connect_opts.custom_headers.strings[i]) {
+ wchar_t *custom_header_wide = NULL;
+
git_str_clear(&buf);
git_str_puts(&buf, t->owner->connect_opts.custom_headers.strings[i]);
- if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_str_cstr(&buf)) < 0) {
- git_error_set(GIT_ERROR_OS, "failed to convert custom header to wide characters");
+
+ /* Convert header to wide characters */
+ if ((error = git__utf8_to_16_alloc(&custom_header_wide, git_str_cstr(&buf))) < 0)
goto on_error;
- }
- if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L,
+ if (!WinHttpAddRequestHeaders(s->request, custom_header_wide, (ULONG)-1L,
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) {
git_error_set(GIT_ERROR_OS, "failed to add a header to the request");
+ git__free(custom_header_wide);
goto on_error;
}
+
+ git__free(custom_header_wide);
}
}