diff options
author | Matt Burke <spraints@gmail.com> | 2015-09-10 08:58:23 -0400 |
---|---|---|
committer | Matt Burke <spraints@gmail.com> | 2015-09-10 08:58:23 -0400 |
commit | 35969c6839c0659ed3ced67bfc5b963662a721f2 (patch) | |
tree | 3dab2ec03d95bf9933b47484f6f2895b4d097f4b | |
parent | c49126c87f1124d0928d68d9191535e5ef4ecd25 (diff) | |
download | libgit2-35969c6839c0659ed3ced67bfc5b963662a721f2.tar.gz |
Ignore NULL headers
-rw-r--r-- | src/transports/http.c | 3 | ||||
-rw-r--r-- | src/transports/winhttp.c | 22 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/transports/http.c b/src/transports/http.c index 764c6a97e..73ea05043 100644 --- a/src/transports/http.c +++ b/src/transports/http.c @@ -213,7 +213,8 @@ static int gen_request( if (t->owner->custom_headers) { for (i = 0; i < t->owner->custom_headers->count; i++) { - git_buf_printf(buf, "%s\r\n", t->owner->custom_headers->strings[i]); + if (t->owner->custom_headers->strings[i]) + git_buf_printf(buf, "%s\r\n", t->owner->custom_headers->strings[i]); } } diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index 8e2bdd44f..5b00d9091 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -412,17 +412,19 @@ static int winhttp_stream_connect(winhttp_stream *s) if (t->owner->custom_headers) { for (i = 0; i < t->owner->custom_headers->count; i++) { - git_buf_clear(&buf); - git_buf_puts(&buf, t->owner->custom_headers->strings[i]); - if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { - giterr_set(GITERR_OS, "Failed to convert custom header to wide characters"); - goto on_error; - } + if (t->owner->custom_headers->strings[i]) { + git_buf_clear(&buf); + git_buf_puts(&buf, t->owner->custom_headers->strings[i]); + if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { + giterr_set(GITERR_OS, "Failed to convert custom header to wide characters"); + goto on_error; + } - if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, - WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { - giterr_set(GITERR_OS, "Failed to add a header to the request"); - goto on_error; + if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, + WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } } } } |