rugged 0.28.4.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/rugged/extconf.rb +3 -1
- data/ext/rugged/rugged.c +35 -31
- data/ext/rugged/rugged.h +13 -0
- data/ext/rugged/rugged_blob.c +11 -9
- data/ext/rugged/rugged_commit.c +18 -16
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +4 -26
- data/ext/rugged/rugged_index.c +4 -2
- data/ext/rugged/rugged_note.c +5 -3
- data/ext/rugged/rugged_object.c +57 -10
- data/ext/rugged/rugged_rebase.c +3 -1
- data/ext/rugged/rugged_remote.c +32 -8
- data/ext/rugged/rugged_repo.c +232 -17
- data/ext/rugged/rugged_tag.c +8 -6
- data/ext/rugged/rugged_tree.c +18 -16
- data/lib/rugged/commit.rb +17 -4
- data/lib/rugged/repository.rb +5 -6
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +57 -75
- data/vendor/libgit2/COPYING +28 -0
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +5 -1
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +2 -2
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +1 -1
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +28 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/FindPCRE.cmake +38 -0
- data/vendor/libgit2/cmake/FindPCRE2.cmake +37 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +2 -2
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +6 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +77 -0
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +48 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +120 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +61 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -0
- data/vendor/libgit2/deps/ntlmclient/compat.h +62 -0
- data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +1419 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
- data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
- data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
- data/vendor/libgit2/deps/pcre/COPYING +5 -0
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
- data/vendor/libgit2/deps/pcre/config.h.in +57 -0
- data/vendor/libgit2/deps/pcre/pcre.h +641 -0
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
- data/vendor/libgit2/deps/pcre/pcre_compile.c +9812 -0
- data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
- data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
- data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
- data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
- data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
- data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
- data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
- data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
- data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
- data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
- data/vendor/libgit2/deps/pcre/pcreposix.c +420 -0
- data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
- data/vendor/libgit2/deps/pcre/ucp.h +224 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +0 -7
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2.h +2 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +22 -2
- data/vendor/libgit2/include/git2/attr.h +23 -13
- data/vendor/libgit2/include/git2/blame.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +44 -12
- data/vendor/libgit2/include/git2/branch.h +74 -57
- data/vendor/libgit2/include/git2/buffer.h +20 -14
- data/vendor/libgit2/include/git2/cert.h +135 -0
- data/vendor/libgit2/include/git2/checkout.h +46 -14
- data/vendor/libgit2/include/git2/cherrypick.h +3 -3
- data/vendor/libgit2/include/git2/clone.h +2 -2
- data/vendor/libgit2/include/git2/commit.h +23 -1
- data/vendor/libgit2/include/git2/common.h +29 -8
- data/vendor/libgit2/include/git2/config.h +12 -12
- data/vendor/libgit2/include/git2/cred_helpers.h +4 -42
- data/vendor/libgit2/include/git2/credential.h +314 -0
- data/vendor/libgit2/include/git2/credential_helpers.h +52 -0
- data/vendor/libgit2/include/git2/deprecated.h +362 -4
- data/vendor/libgit2/include/git2/describe.h +4 -4
- data/vendor/libgit2/include/git2/diff.h +16 -14
- data/vendor/libgit2/include/git2/errors.h +5 -2
- data/vendor/libgit2/include/git2/filter.h +8 -0
- data/vendor/libgit2/include/git2/index.h +3 -3
- data/vendor/libgit2/include/git2/indexer.h +48 -4
- data/vendor/libgit2/include/git2/merge.h +6 -10
- data/vendor/libgit2/include/git2/net.h +0 -5
- data/vendor/libgit2/include/git2/object.h +2 -14
- data/vendor/libgit2/include/git2/odb.h +3 -2
- data/vendor/libgit2/include/git2/odb_backend.h +5 -4
- data/vendor/libgit2/include/git2/oid.h +11 -6
- data/vendor/libgit2/include/git2/pack.h +13 -2
- data/vendor/libgit2/include/git2/proxy.h +6 -4
- data/vendor/libgit2/include/git2/rebase.h +46 -2
- data/vendor/libgit2/include/git2/refs.h +19 -0
- data/vendor/libgit2/include/git2/remote.h +40 -15
- data/vendor/libgit2/include/git2/repository.h +29 -6
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +7 -3
- data/vendor/libgit2/include/git2/stash.h +4 -4
- data/vendor/libgit2/include/git2/status.h +25 -16
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- data/vendor/libgit2/include/git2/submodule.h +20 -3
- data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
- data/vendor/libgit2/include/git2/sys/cred.h +15 -0
- data/vendor/libgit2/include/git2/sys/credential.h +90 -0
- data/vendor/libgit2/include/git2/sys/index.h +4 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +2 -1
- data/vendor/libgit2/include/git2/sys/merge.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +164 -21
- data/vendor/libgit2/include/git2/sys/repository.h +17 -6
- data/vendor/libgit2/include/git2/sys/transport.h +4 -4
- data/vendor/libgit2/include/git2/tag.h +11 -2
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transport.h +11 -340
- data/vendor/libgit2/include/git2/tree.h +5 -3
- data/vendor/libgit2/include/git2/types.h +4 -89
- data/vendor/libgit2/include/git2/version.h +5 -5
- data/vendor/libgit2/include/git2/worktree.h +5 -5
- data/vendor/libgit2/src/CMakeLists.txt +147 -272
- data/vendor/libgit2/src/alloc.c +2 -14
- data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
- data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
- data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
- data/vendor/libgit2/src/apply.c +65 -31
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +70 -64
- data/vendor/libgit2/src/attr_file.c +197 -99
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +49 -50
- data/vendor/libgit2/src/attrcache.h +2 -1
- data/vendor/libgit2/src/blame.c +19 -5
- data/vendor/libgit2/src/blame.h +1 -1
- data/vendor/libgit2/src/blame_git.c +27 -10
- data/vendor/libgit2/src/blob.c +83 -17
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +68 -42
- data/vendor/libgit2/src/buffer.c +25 -10
- data/vendor/libgit2/src/buffer.h +1 -0
- data/vendor/libgit2/src/cache.c +34 -58
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +5 -0
- data/vendor/libgit2/src/checkout.c +73 -86
- data/vendor/libgit2/src/cherrypick.c +11 -3
- data/vendor/libgit2/src/clone.c +107 -25
- data/vendor/libgit2/src/clone.h +4 -0
- data/vendor/libgit2/src/commit.c +70 -22
- data/vendor/libgit2/src/commit.h +6 -0
- data/vendor/libgit2/src/commit_list.c +28 -76
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +4 -75
- data/vendor/libgit2/src/config.c +34 -47
- data/vendor/libgit2/src/config.h +7 -6
- data/vendor/libgit2/src/config_backend.h +12 -0
- data/vendor/libgit2/src/config_cache.c +39 -39
- data/vendor/libgit2/src/config_entries.c +76 -98
- data/vendor/libgit2/src/config_entries.h +1 -0
- data/vendor/libgit2/src/config_file.c +346 -380
- data/vendor/libgit2/src/config_mem.c +12 -16
- data/vendor/libgit2/src/config_parse.c +50 -30
- data/vendor/libgit2/src/config_parse.h +13 -12
- data/vendor/libgit2/src/config_snapshot.c +207 -0
- data/vendor/libgit2/src/crlf.c +14 -14
- data/vendor/libgit2/src/describe.c +26 -21
- data/vendor/libgit2/src/diff.c +53 -67
- data/vendor/libgit2/src/diff.h +4 -3
- data/vendor/libgit2/src/diff_driver.c +37 -38
- data/vendor/libgit2/src/diff_file.c +15 -11
- data/vendor/libgit2/src/diff_file.h +2 -2
- data/vendor/libgit2/src/diff_generate.c +158 -109
- data/vendor/libgit2/src/diff_generate.h +2 -2
- data/vendor/libgit2/src/diff_parse.c +3 -4
- data/vendor/libgit2/src/diff_print.c +86 -71
- data/vendor/libgit2/src/diff_stats.c +13 -12
- data/vendor/libgit2/src/diff_tform.c +13 -14
- data/vendor/libgit2/src/errors.c +23 -25
- data/vendor/libgit2/src/errors.h +81 -0
- data/vendor/libgit2/src/features.h.in +9 -2
- data/vendor/libgit2/src/fetch.c +9 -2
- data/vendor/libgit2/src/fetchhead.c +36 -4
- data/vendor/libgit2/src/filebuf.c +6 -10
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/filter.c +19 -11
- data/vendor/libgit2/src/{fileops.c → futils.c} +24 -20
- data/vendor/libgit2/src/{fileops.h → futils.h} +8 -8
- data/vendor/libgit2/src/global.c +15 -41
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/hash.c +61 -0
- data/vendor/libgit2/src/hash.h +19 -21
- data/vendor/libgit2/src/hash/sha1.h +38 -0
- data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
- data/vendor/libgit2/src/{sha1_lookup.h → hash/sha1/collisiondetect.h} +8 -8
- data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
- data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
- data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
- data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
- data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
- data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
- data/vendor/libgit2/src/{refdb_fs.h → hash/sha1/openssl.h} +8 -8
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
- data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/idxmap.c +73 -69
- data/vendor/libgit2/src/idxmap.h +151 -15
- data/vendor/libgit2/src/ignore.c +32 -38
- data/vendor/libgit2/src/index.c +117 -90
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +80 -75
- data/vendor/libgit2/src/integer.h +39 -4
- data/vendor/libgit2/src/iterator.c +44 -39
- data/vendor/libgit2/src/iterator.h +8 -8
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +91 -58
- data/vendor/libgit2/src/merge.h +2 -2
- data/vendor/libgit2/src/merge_driver.c +5 -5
- data/vendor/libgit2/src/merge_file.c +5 -7
- data/vendor/libgit2/src/midx.c +418 -0
- data/vendor/libgit2/src/midx.h +83 -0
- data/vendor/libgit2/src/mwindow.c +142 -74
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/net.c +416 -0
- data/vendor/libgit2/src/net.h +57 -0
- data/vendor/libgit2/src/netops.c +6 -193
- data/vendor/libgit2/src/netops.h +1 -34
- data/vendor/libgit2/src/notes.c +8 -5
- data/vendor/libgit2/src/object.c +5 -4
- data/vendor/libgit2/src/object.h +2 -0
- data/vendor/libgit2/src/odb.c +50 -29
- data/vendor/libgit2/src/odb.h +3 -2
- data/vendor/libgit2/src/odb_loose.c +20 -13
- data/vendor/libgit2/src/odb_mempack.c +15 -24
- data/vendor/libgit2/src/odb_pack.c +4 -5
- data/vendor/libgit2/src/offmap.c +43 -55
- data/vendor/libgit2/src/offmap.h +102 -24
- data/vendor/libgit2/src/oid.c +21 -8
- data/vendor/libgit2/src/oidmap.c +39 -57
- data/vendor/libgit2/src/oidmap.h +99 -19
- data/vendor/libgit2/src/pack-objects.c +55 -52
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +154 -147
- data/vendor/libgit2/src/pack.h +32 -18
- data/vendor/libgit2/src/parse.c +10 -0
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +3 -5
- data/vendor/libgit2/src/patch_parse.c +134 -35
- data/vendor/libgit2/src/path.c +47 -10
- data/vendor/libgit2/src/path.h +2 -0
- data/vendor/libgit2/src/pathspec.c +18 -17
- data/vendor/libgit2/src/pool.c +42 -32
- data/vendor/libgit2/src/pool.h +15 -7
- data/vendor/libgit2/src/posix.c +7 -7
- data/vendor/libgit2/src/posix.h +12 -1
- data/vendor/libgit2/src/proxy.c +9 -2
- data/vendor/libgit2/src/push.c +15 -7
- data/vendor/libgit2/src/reader.c +2 -2
- data/vendor/libgit2/src/rebase.c +89 -28
- data/vendor/libgit2/src/refdb.c +147 -0
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +230 -240
- data/vendor/libgit2/src/reflog.c +13 -19
- data/vendor/libgit2/src/refs.c +98 -210
- data/vendor/libgit2/src/refs.h +9 -20
- data/vendor/libgit2/src/refspec.c +9 -16
- data/vendor/libgit2/src/regexp.c +221 -0
- data/vendor/libgit2/src/regexp.h +97 -0
- data/vendor/libgit2/src/remote.c +89 -72
- data/vendor/libgit2/src/remote.h +2 -2
- data/vendor/libgit2/src/repository.c +317 -195
- data/vendor/libgit2/src/repository.h +49 -57
- data/vendor/libgit2/src/revert.c +10 -3
- data/vendor/libgit2/src/revparse.c +23 -23
- data/vendor/libgit2/src/revwalk.c +73 -37
- data/vendor/libgit2/src/revwalk.h +20 -0
- data/vendor/libgit2/src/settings.c +22 -1
- data/vendor/libgit2/src/sortedcache.c +14 -29
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +49 -67
- data/vendor/libgit2/src/status.c +19 -11
- data/vendor/libgit2/src/strarray.c +63 -0
- data/vendor/libgit2/src/streams/openssl.c +66 -8
- data/vendor/libgit2/src/streams/registry.c +5 -3
- data/vendor/libgit2/src/streams/socket.c +2 -2
- data/vendor/libgit2/src/strmap.c +37 -84
- data/vendor/libgit2/src/strmap.h +105 -33
- data/vendor/libgit2/src/submodule.c +157 -130
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +15 -21
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +12 -2
- data/vendor/libgit2/src/thread-utils.h +139 -21
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/trailer.c +46 -32
- data/vendor/libgit2/src/transaction.c +12 -10
- data/vendor/libgit2/src/transports/auth.c +16 -15
- data/vendor/libgit2/src/transports/auth.h +18 -11
- data/vendor/libgit2/src/transports/auth_negotiate.c +64 -33
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
- data/vendor/libgit2/src/transports/auth_ntlm.h +38 -0
- data/vendor/libgit2/src/transports/credential.c +478 -0
- data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +23 -8
- data/vendor/libgit2/src/transports/git.c +11 -16
- data/vendor/libgit2/src/transports/http.c +488 -1248
- data/vendor/libgit2/src/transports/http.h +4 -1
- data/vendor/libgit2/src/transports/httpclient.c +1547 -0
- data/vendor/libgit2/src/transports/httpclient.h +190 -0
- data/vendor/libgit2/src/transports/local.c +12 -12
- data/vendor/libgit2/src/transports/smart.c +21 -21
- data/vendor/libgit2/src/transports/smart.h +3 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +40 -64
- data/vendor/libgit2/src/transports/ssh.c +77 -59
- data/vendor/libgit2/src/transports/winhttp.c +290 -249
- data/vendor/libgit2/src/tree-cache.c +14 -7
- data/vendor/libgit2/src/tree.c +16 -26
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +15 -13
- data/vendor/libgit2/src/userdiff.h +3 -1
- data/vendor/libgit2/src/util.c +75 -110
- data/vendor/libgit2/src/util.h +18 -23
- data/vendor/libgit2/src/wildmatch.c +320 -0
- data/vendor/libgit2/src/wildmatch.h +23 -0
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/map.c +3 -5
- data/vendor/libgit2/src/win32/path_w32.c +42 -5
- data/vendor/libgit2/src/win32/path_w32.h +15 -29
- data/vendor/libgit2/src/win32/posix.h +1 -4
- data/vendor/libgit2/src/win32/posix_w32.c +47 -5
- data/vendor/libgit2/src/win32/precompiled.h +0 -2
- data/vendor/libgit2/src/win32/thread.c +5 -10
- data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
- data/vendor/libgit2/src/win32/w32_common.h +39 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
- data/vendor/libgit2/src/win32/w32_stack.c +4 -9
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +31 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -32
- data/vendor/libgit2/src/worktree.c +83 -49
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
- data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
- data/vendor/libgit2/src/zstream.c +5 -0
- data/vendor/libgit2/src/zstream.h +1 -0
- metadata +124 -55
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
- data/vendor/libgit2/deps/regex/COPYING +0 -502
- data/vendor/libgit2/deps/regex/config.h +0 -7
- data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
- data/vendor/libgit2/deps/regex/regex.c +0 -92
- data/vendor/libgit2/deps/regex/regex.h +0 -582
- data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
- data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
- data/vendor/libgit2/deps/regex/regexec.c +0 -4369
- data/vendor/libgit2/include/git2/inttypes.h +0 -309
- data/vendor/libgit2/include/git2/sys/time.h +0 -31
- data/vendor/libgit2/libgit2.pc.in +0 -13
- data/vendor/libgit2/src/fnmatch.c +0 -248
- data/vendor/libgit2/src/fnmatch.h +0 -48
- data/vendor/libgit2/src/sha1_lookup.c +0 -35
- data/vendor/libgit2/src/transports/cred.c +0 -390
@@ -19,6 +19,7 @@
|
|
19
19
|
#include "repository.h"
|
20
20
|
#include "global.h"
|
21
21
|
#include "http.h"
|
22
|
+
#include "git2/sys/credential.h"
|
22
23
|
|
23
24
|
#include <wincrypt.h>
|
24
25
|
#include <winhttp.h>
|
@@ -40,14 +41,28 @@
|
|
40
41
|
#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0
|
41
42
|
#endif
|
42
43
|
|
43
|
-
#ifndef
|
44
|
+
#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1
|
44
45
|
# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200
|
45
46
|
#endif
|
46
47
|
|
47
|
-
#ifndef
|
48
|
+
#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
|
48
49
|
# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
|
49
50
|
#endif
|
50
51
|
|
52
|
+
#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3
|
53
|
+
# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 0x00002000
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#ifndef HTTP_STATUS_PERMANENT_REDIRECT
|
57
|
+
# define HTTP_STATUS_PERMANENT_REDIRECT 308
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#ifndef DWORD_MAX
|
61
|
+
# define DWORD_MAX 0xffffffff
|
62
|
+
#endif
|
63
|
+
|
64
|
+
bool git_http__expect_continue = false;
|
65
|
+
|
51
66
|
static const char *prefix_https = "https://";
|
52
67
|
static const char *upload_pack_service = "upload-pack";
|
53
68
|
static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack";
|
@@ -100,24 +115,44 @@ typedef struct {
|
|
100
115
|
chunked : 1;
|
101
116
|
} winhttp_stream;
|
102
117
|
|
118
|
+
typedef struct {
|
119
|
+
git_net_url url;
|
120
|
+
git_credential *cred;
|
121
|
+
int auth_mechanisms;
|
122
|
+
bool url_cred_presented;
|
123
|
+
} winhttp_server;
|
124
|
+
|
103
125
|
typedef struct {
|
104
126
|
git_smart_subtransport parent;
|
105
127
|
transport_smart *owner;
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
git_cred *proxy_cred;
|
111
|
-
int auth_mechanisms;
|
128
|
+
|
129
|
+
winhttp_server server;
|
130
|
+
winhttp_server proxy;
|
131
|
+
|
112
132
|
HINTERNET session;
|
113
133
|
HINTERNET connection;
|
114
134
|
} winhttp_subtransport;
|
115
135
|
|
116
|
-
static int
|
136
|
+
static int apply_userpass_credentials(HINTERNET request, DWORD target, int mechanisms, git_credential *cred)
|
117
137
|
{
|
118
|
-
|
119
|
-
wchar_t *user, *pass;
|
138
|
+
git_credential_userpass_plaintext *c = (git_credential_userpass_plaintext *)cred;
|
139
|
+
wchar_t *user = NULL, *pass = NULL;
|
120
140
|
int user_len = 0, pass_len = 0, error = 0;
|
141
|
+
DWORD native_scheme;
|
142
|
+
|
143
|
+
if (mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) {
|
144
|
+
native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
|
145
|
+
} else if (mechanisms & GIT_WINHTTP_AUTH_NTLM) {
|
146
|
+
native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
|
147
|
+
} else if (mechanisms & GIT_WINHTTP_AUTH_DIGEST) {
|
148
|
+
native_scheme = WINHTTP_AUTH_SCHEME_DIGEST;
|
149
|
+
} else if (mechanisms & GIT_WINHTTP_AUTH_BASIC) {
|
150
|
+
native_scheme = WINHTTP_AUTH_SCHEME_BASIC;
|
151
|
+
} else {
|
152
|
+
git_error_set(GIT_ERROR_HTTP, "invalid authentication scheme");
|
153
|
+
error = -1;
|
154
|
+
goto done;
|
155
|
+
}
|
121
156
|
|
122
157
|
if ((error = user_len = git__utf8_to_16_alloc(&user, c->username)) < 0)
|
123
158
|
goto done;
|
@@ -125,7 +160,7 @@ static int _apply_userpass_credential(HINTERNET request, DWORD target, DWORD sch
|
|
125
160
|
if ((error = pass_len = git__utf8_to_16_alloc(&pass, c->password)) < 0)
|
126
161
|
goto done;
|
127
162
|
|
128
|
-
if (!WinHttpSetCredentials(request, target,
|
163
|
+
if (!WinHttpSetCredentials(request, target, native_scheme, user, pass, NULL)) {
|
129
164
|
git_error_set(GIT_ERROR_OS, "failed to set credentials");
|
130
165
|
error = -1;
|
131
166
|
}
|
@@ -143,81 +178,62 @@ done:
|
|
143
178
|
return error;
|
144
179
|
}
|
145
180
|
|
146
|
-
static int
|
147
|
-
{
|
148
|
-
if (GIT_WINHTTP_AUTH_DIGEST & mechanisms) {
|
149
|
-
return _apply_userpass_credential(request, WINHTTP_AUTH_TARGET_PROXY,
|
150
|
-
WINHTTP_AUTH_SCHEME_DIGEST, cred);
|
151
|
-
}
|
152
|
-
|
153
|
-
return _apply_userpass_credential(request, WINHTTP_AUTH_TARGET_PROXY,
|
154
|
-
WINHTTP_AUTH_SCHEME_BASIC, cred);
|
155
|
-
}
|
156
|
-
|
157
|
-
static int apply_userpass_credential(HINTERNET request, int mechanisms, git_cred *cred)
|
181
|
+
static int apply_default_credentials(HINTERNET request, DWORD target, int mechanisms)
|
158
182
|
{
|
159
|
-
DWORD
|
183
|
+
DWORD autologon_level = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
|
184
|
+
DWORD native_scheme = 0;
|
160
185
|
|
161
|
-
if ((mechanisms &
|
162
|
-
|
186
|
+
if ((mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) != 0) {
|
187
|
+
native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
|
188
|
+
} else if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) != 0) {
|
163
189
|
native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
|
164
|
-
} else if (mechanisms & GIT_WINHTTP_AUTH_BASIC) {
|
165
|
-
native_scheme = WINHTTP_AUTH_SCHEME_BASIC;
|
166
190
|
} else {
|
167
|
-
git_error_set(
|
191
|
+
git_error_set(GIT_ERROR_HTTP, "invalid authentication scheme");
|
168
192
|
return -1;
|
169
193
|
}
|
170
194
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
/* Either the caller explicitly requested that default credentials be passed,
|
178
|
-
* or our fallback credential callback was invoked and checked that the target
|
179
|
-
* URI was in the appropriate Internet Explorer security zone. By setting this
|
180
|
-
* flag, we guarantee that the credentials are delivered by WinHTTP. The default
|
181
|
-
* is "medium" which applies to the intranet and sounds like it would correspond
|
182
|
-
* to Internet Explorer security zones, but in fact does not. */
|
183
|
-
DWORD data = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
|
184
|
-
DWORD native_scheme = 0;
|
185
|
-
|
186
|
-
if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) != 0)
|
187
|
-
native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
|
188
|
-
|
189
|
-
if ((mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) != 0)
|
190
|
-
native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
|
191
|
-
|
192
|
-
if (!native_scheme) {
|
193
|
-
git_error_set(GIT_ERROR_NET, "invalid authentication scheme");
|
195
|
+
/*
|
196
|
+
* Autologon policy must be "low" to use default creds.
|
197
|
+
* This is safe as the user has explicitly requested it.
|
198
|
+
*/
|
199
|
+
if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &autologon_level, sizeof(DWORD))) {
|
200
|
+
git_error_set(GIT_ERROR_OS, "could not configure logon policy");
|
194
201
|
return -1;
|
195
202
|
}
|
196
203
|
|
197
|
-
if (!
|
198
|
-
|
199
|
-
|
200
|
-
if (!WinHttpSetCredentials(request, WINHTTP_AUTH_TARGET_SERVER, native_scheme, NULL, NULL, NULL))
|
204
|
+
if (!WinHttpSetCredentials(request, target, native_scheme, NULL, NULL, NULL)) {
|
205
|
+
git_error_set(GIT_ERROR_OS, "could not configure credentials");
|
201
206
|
return -1;
|
207
|
+
}
|
202
208
|
|
203
209
|
return 0;
|
204
210
|
}
|
205
211
|
|
206
|
-
static int
|
207
|
-
|
208
|
-
const char *url,
|
209
|
-
const char *username_from_url,
|
212
|
+
static int acquire_url_cred(
|
213
|
+
git_credential **cred,
|
210
214
|
unsigned int allowed_types,
|
211
|
-
|
215
|
+
const char *username,
|
216
|
+
const char *password)
|
212
217
|
{
|
213
|
-
|
218
|
+
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT)
|
219
|
+
return git_credential_userpass_plaintext_new(cred, username, password);
|
220
|
+
|
221
|
+
if ((allowed_types & GIT_CREDENTIAL_DEFAULT) && *username == '\0' && *password == '\0')
|
222
|
+
return git_credential_default_new(cred);
|
214
223
|
|
215
|
-
|
216
|
-
|
224
|
+
return 1;
|
225
|
+
}
|
226
|
+
|
227
|
+
static int acquire_fallback_cred(
|
228
|
+
git_credential **cred,
|
229
|
+
const char *url,
|
230
|
+
unsigned int allowed_types)
|
231
|
+
{
|
232
|
+
int error = 1;
|
217
233
|
|
218
234
|
/* If the target URI supports integrated Windows authentication
|
219
235
|
* as an authentication mechanism */
|
220
|
-
if (
|
236
|
+
if (GIT_CREDENTIAL_DEFAULT & allowed_types) {
|
221
237
|
wchar_t *wide_url;
|
222
238
|
HRESULT hCoInitResult;
|
223
239
|
|
@@ -241,21 +257,21 @@ static int fallback_cred_acquire_cb(
|
|
241
257
|
(URLZONE_LOCAL_MACHINE == dwZone ||
|
242
258
|
URLZONE_INTRANET == dwZone ||
|
243
259
|
URLZONE_TRUSTED == dwZone)) {
|
244
|
-
|
260
|
+
git_credential *existing = *cred;
|
245
261
|
|
246
262
|
if (existing)
|
247
263
|
existing->free(existing);
|
248
264
|
|
249
265
|
/* Then use default Windows credentials to authenticate this request */
|
250
|
-
error =
|
266
|
+
error = git_credential_default_new(cred);
|
251
267
|
}
|
252
268
|
|
253
269
|
pISM->lpVtbl->Release(pISM);
|
254
270
|
}
|
255
271
|
|
256
|
-
|
257
|
-
|
258
|
-
|
272
|
+
/* Only unitialize if the call to CoInitializeEx was successful. */
|
273
|
+
if (SUCCEEDED(hCoInitResult))
|
274
|
+
CoUninitialize();
|
259
275
|
}
|
260
276
|
|
261
277
|
git__free(wide_url);
|
@@ -275,12 +291,12 @@ static int certificate_check(winhttp_stream *s, int valid)
|
|
275
291
|
/* If there is no override, we should fail if WinHTTP doesn't think it's fine */
|
276
292
|
if (t->owner->certificate_check_cb == NULL && !valid) {
|
277
293
|
if (!git_error_last())
|
278
|
-
git_error_set(
|
294
|
+
git_error_set(GIT_ERROR_HTTP, "unknown certificate check failure");
|
279
295
|
|
280
296
|
return GIT_ECERTIFICATE;
|
281
297
|
}
|
282
298
|
|
283
|
-
if (t->owner->certificate_check_cb == NULL ||
|
299
|
+
if (t->owner->certificate_check_cb == NULL || git__strcmp(t->server.url.scheme, "https") != 0)
|
284
300
|
return 0;
|
285
301
|
|
286
302
|
if (!WinHttpQueryOption(s->request, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert_ctx, &cert_ctx_size)) {
|
@@ -292,14 +308,14 @@ static int certificate_check(winhttp_stream *s, int valid)
|
|
292
308
|
cert.parent.cert_type = GIT_CERT_X509;
|
293
309
|
cert.data = cert_ctx->pbCertEncoded;
|
294
310
|
cert.len = cert_ctx->cbCertEncoded;
|
295
|
-
error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->
|
311
|
+
error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->server.url.host, t->owner->message_cb_payload);
|
296
312
|
CertFreeCertificateContext(cert_ctx);
|
297
313
|
|
298
314
|
if (error == GIT_PASSTHROUGH)
|
299
315
|
error = valid ? 0 : GIT_ECERTIFICATE;
|
300
316
|
|
301
317
|
if (error < 0 && !git_error_last())
|
302
|
-
git_error_set(
|
318
|
+
git_error_set(GIT_ERROR_HTTP, "user cancelled certificate check");
|
303
319
|
|
304
320
|
return error;
|
305
321
|
}
|
@@ -329,8 +345,25 @@ static void winhttp_stream_close(winhttp_stream *s)
|
|
329
345
|
s->sent_request = 0;
|
330
346
|
}
|
331
347
|
|
332
|
-
|
333
|
-
|
348
|
+
static int apply_credentials(
|
349
|
+
HINTERNET request,
|
350
|
+
git_net_url *url,
|
351
|
+
int target,
|
352
|
+
git_credential *creds,
|
353
|
+
int mechanisms)
|
354
|
+
{
|
355
|
+
int error = 0;
|
356
|
+
|
357
|
+
GIT_UNUSED(url);
|
358
|
+
|
359
|
+
/* If we have creds, just apply them */
|
360
|
+
if (creds && creds->credtype == GIT_CREDENTIAL_USERPASS_PLAINTEXT)
|
361
|
+
error = apply_userpass_credentials(request, target, mechanisms, creds);
|
362
|
+
else if (creds && creds->credtype == GIT_CREDENTIAL_DEFAULT)
|
363
|
+
error = apply_default_credentials(request, target, mechanisms);
|
364
|
+
|
365
|
+
return error;
|
366
|
+
}
|
334
367
|
|
335
368
|
static int winhttp_stream_connect(winhttp_stream *s)
|
336
369
|
{
|
@@ -344,11 +377,17 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
344
377
|
unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS;
|
345
378
|
int default_timeout = TIMEOUT_INFINITE;
|
346
379
|
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
380
|
+
DWORD autologon_policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH;
|
381
|
+
|
382
|
+
const char *service_url = s->service_url;
|
347
383
|
size_t i;
|
348
384
|
const git_proxy_options *proxy_opts;
|
349
385
|
|
386
|
+
/* If path already ends in /, remove the leading slash from service_url */
|
387
|
+
if ((git__suffixcmp(t->server.url.path, "/") == 0) && (git__prefixcmp(service_url, "/") == 0))
|
388
|
+
service_url++;
|
350
389
|
/* Prepare URL */
|
351
|
-
git_buf_printf(&buf, "%s%s", t->
|
390
|
+
git_buf_printf(&buf, "%s%s", t->server.url.path, service_url);
|
352
391
|
|
353
392
|
if (git_buf_oom(&buf))
|
354
393
|
return -1;
|
@@ -367,13 +406,17 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
367
406
|
NULL,
|
368
407
|
WINHTTP_NO_REFERER,
|
369
408
|
types,
|
370
|
-
t->
|
409
|
+
git__strcmp(t->server.url.scheme, "https") == 0 ? WINHTTP_FLAG_SECURE : 0);
|
371
410
|
|
372
411
|
if (!s->request) {
|
373
412
|
git_error_set(GIT_ERROR_OS, "failed to open request");
|
374
413
|
goto on_error;
|
375
414
|
}
|
376
415
|
|
416
|
+
/* Never attempt default credentials; we'll provide them explicitly. */
|
417
|
+
if (!WinHttpSetOption(s->request, WINHTTP_OPTION_AUTOLOGON_POLICY, &autologon_policy, sizeof(DWORD)))
|
418
|
+
return -1;
|
419
|
+
|
377
420
|
if (!WinHttpSetTimeouts(s->request, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
|
378
421
|
git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP");
|
379
422
|
goto on_error;
|
@@ -382,7 +425,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
382
425
|
proxy_opts = &t->owner->proxy;
|
383
426
|
if (proxy_opts->type == GIT_PROXY_AUTO) {
|
384
427
|
/* Set proxy if necessary */
|
385
|
-
if (git_remote__get_http_proxy(t->owner->owner,
|
428
|
+
if (git_remote__get_http_proxy(t->owner->owner, (strcmp(t->server.url.scheme, "https") == 0), &proxy_url) < 0)
|
386
429
|
goto on_error;
|
387
430
|
}
|
388
431
|
else if (proxy_opts->type == GIT_PROXY_SPECIFIED) {
|
@@ -395,38 +438,24 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
395
438
|
WINHTTP_PROXY_INFO proxy_info;
|
396
439
|
wchar_t *proxy_wide;
|
397
440
|
|
398
|
-
|
399
|
-
t->proxy_connection_data.use_ssl = false;
|
400
|
-
} else if (!git__prefixcmp(proxy_url, SCHEME_HTTPS)) {
|
401
|
-
t->proxy_connection_data.use_ssl = true;
|
402
|
-
} else {
|
403
|
-
git_error_set(GIT_ERROR_NET, "invalid URL: '%s'", proxy_url);
|
404
|
-
return -1;
|
405
|
-
}
|
441
|
+
git_net_url_dispose(&t->proxy.url);
|
406
442
|
|
407
|
-
|
408
|
-
|
409
|
-
if ((error = gitno_extract_url_parts(&t->proxy_connection_data.host, &t->proxy_connection_data.port, NULL,
|
410
|
-
&t->proxy_connection_data.user, &t->proxy_connection_data.pass, proxy_url, NULL)) < 0)
|
443
|
+
if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
|
411
444
|
goto on_error;
|
412
445
|
|
413
|
-
if (t->
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
if ((error = git_cred_userpass_plaintext_new(&t->proxy_cred, t->proxy_connection_data.user, t->proxy_connection_data.pass)) < 0)
|
419
|
-
goto on_error;
|
446
|
+
if (strcmp(t->proxy.url.scheme, "http") != 0 && strcmp(t->proxy.url.scheme, "https") != 0) {
|
447
|
+
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy_url);
|
448
|
+
error = -1;
|
449
|
+
goto on_error;
|
420
450
|
}
|
421
451
|
|
422
|
-
|
423
|
-
|
424
|
-
else
|
425
|
-
git_buf_PUTS(&processed_url, SCHEME_HTTP);
|
452
|
+
git_buf_puts(&processed_url, t->proxy.url.scheme);
|
453
|
+
git_buf_PUTS(&processed_url, "://");
|
426
454
|
|
427
|
-
git_buf_puts(&processed_url, t->
|
428
|
-
|
429
|
-
|
455
|
+
git_buf_puts(&processed_url, t->proxy.url.host);
|
456
|
+
|
457
|
+
if (!git_net_url_is_default_port(&t->proxy.url))
|
458
|
+
git_buf_printf(&processed_url, ":%s", t->proxy.url.port);
|
430
459
|
|
431
460
|
if (git_buf_oom(&processed_url)) {
|
432
461
|
error = -1;
|
@@ -454,13 +483,8 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
454
483
|
|
455
484
|
git__free(proxy_wide);
|
456
485
|
|
457
|
-
if (t->
|
458
|
-
|
459
|
-
if ((error = apply_userpass_credential_proxy(s->request, t->proxy_cred, t->auth_mechanisms)) < 0)
|
460
|
-
goto on_error;
|
461
|
-
}
|
462
|
-
}
|
463
|
-
|
486
|
+
if ((error = apply_credentials(s->request, &t->proxy.url, WINHTTP_AUTH_TARGET_PROXY, t->proxy.cred, t->proxy.auth_mechanisms)) < 0)
|
487
|
+
goto on_error;
|
464
488
|
}
|
465
489
|
|
466
490
|
/* Disable WinHTTP redirects so we can handle them manually. Why, you ask?
|
@@ -471,6 +495,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
471
495
|
&disable_redirects,
|
472
496
|
sizeof(disable_redirects))) {
|
473
497
|
git_error_set(GIT_ERROR_OS, "failed to disable redirects");
|
498
|
+
error = -1;
|
474
499
|
goto on_error;
|
475
500
|
}
|
476
501
|
|
@@ -543,32 +568,15 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
543
568
|
}
|
544
569
|
|
545
570
|
/* If requested, disable certificate validation */
|
546
|
-
if (t->
|
571
|
+
if (strcmp(t->server.url.scheme, "https") == 0) {
|
547
572
|
int flags;
|
548
573
|
|
549
574
|
if (t->owner->parent.read_flags(&t->owner->parent, &flags) < 0)
|
550
575
|
goto on_error;
|
551
576
|
}
|
552
577
|
|
553
|
-
|
554
|
-
if (t->cred &&
|
555
|
-
t->cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT &&
|
556
|
-
apply_userpass_credential(s->request, t->auth_mechanisms, t->cred) < 0)
|
578
|
+
if ((error = apply_credentials(s->request, &t->server.url, WINHTTP_AUTH_TARGET_SERVER, t->server.cred, t->server.auth_mechanisms)) < 0)
|
557
579
|
goto on_error;
|
558
|
-
else if (t->cred &&
|
559
|
-
t->cred->credtype == GIT_CREDTYPE_DEFAULT &&
|
560
|
-
apply_default_credentials(s->request, t->auth_mechanisms) < 0)
|
561
|
-
goto on_error;
|
562
|
-
|
563
|
-
/* If no other credentials have been applied and the URL has username and
|
564
|
-
* password, use those */
|
565
|
-
if (!t->cred && t->connection_data.user && t->connection_data.pass) {
|
566
|
-
if (!t->url_cred &&
|
567
|
-
git_cred_userpass_plaintext_new(&t->url_cred, t->connection_data.user, t->connection_data.pass) < 0)
|
568
|
-
goto on_error;
|
569
|
-
if (apply_userpass_credential(s->request, GIT_WINHTTP_AUTH_BASIC, t->url_cred) < 0)
|
570
|
-
goto on_error;
|
571
|
-
}
|
572
580
|
|
573
581
|
/* We've done everything up to calling WinHttpSendRequest. */
|
574
582
|
|
@@ -584,9 +592,9 @@ on_error:
|
|
584
592
|
}
|
585
593
|
|
586
594
|
static int parse_unauthorized_response(
|
587
|
-
HINTERNET request,
|
588
595
|
int *allowed_types,
|
589
|
-
int *allowed_mechanisms
|
596
|
+
int *allowed_mechanisms,
|
597
|
+
HINTERNET request)
|
590
598
|
{
|
591
599
|
DWORD supported, first, target;
|
592
600
|
|
@@ -602,23 +610,23 @@ static int parse_unauthorized_response(
|
|
602
610
|
}
|
603
611
|
|
604
612
|
if (WINHTTP_AUTH_SCHEME_NTLM & supported) {
|
605
|
-
*allowed_types |=
|
606
|
-
*allowed_types |=
|
613
|
+
*allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
|
614
|
+
*allowed_types |= GIT_CREDENTIAL_DEFAULT;
|
607
615
|
*allowed_mechanisms |= GIT_WINHTTP_AUTH_NTLM;
|
608
616
|
}
|
609
617
|
|
610
618
|
if (WINHTTP_AUTH_SCHEME_NEGOTIATE & supported) {
|
611
|
-
*allowed_types |=
|
619
|
+
*allowed_types |= GIT_CREDENTIAL_DEFAULT;
|
612
620
|
*allowed_mechanisms |= GIT_WINHTTP_AUTH_NEGOTIATE;
|
613
621
|
}
|
614
622
|
|
615
623
|
if (WINHTTP_AUTH_SCHEME_BASIC & supported) {
|
616
|
-
*allowed_types |=
|
624
|
+
*allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
|
617
625
|
*allowed_mechanisms |= GIT_WINHTTP_AUTH_BASIC;
|
618
626
|
}
|
619
627
|
|
620
628
|
if (WINHTTP_AUTH_SCHEME_DIGEST & supported) {
|
621
|
-
*allowed_types |=
|
629
|
+
*allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
|
622
630
|
*allowed_mechanisms |= GIT_WINHTTP_AUTH_DIGEST;
|
623
631
|
}
|
624
632
|
|
@@ -699,27 +707,31 @@ static void CALLBACK winhttp_status(
|
|
699
707
|
{
|
700
708
|
DWORD status;
|
701
709
|
|
710
|
+
GIT_UNUSED(connection);
|
711
|
+
GIT_UNUSED(ctx);
|
712
|
+
GIT_UNUSED(info_len);
|
713
|
+
|
702
714
|
if (code != WINHTTP_CALLBACK_STATUS_SECURE_FAILURE)
|
703
715
|
return;
|
704
716
|
|
705
717
|
status = *((DWORD *)info);
|
706
718
|
|
707
719
|
if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID))
|
708
|
-
git_error_set(
|
720
|
+
git_error_set(GIT_ERROR_HTTP, "SSL certificate issued for different common name");
|
709
721
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID))
|
710
|
-
git_error_set(
|
722
|
+
git_error_set(GIT_ERROR_HTTP, "SSL certificate has expired");
|
711
723
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA))
|
712
|
-
git_error_set(
|
724
|
+
git_error_set(GIT_ERROR_HTTP, "SSL certificate signed by unknown CA");
|
713
725
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT))
|
714
|
-
git_error_set(
|
726
|
+
git_error_set(GIT_ERROR_HTTP, "SSL certificate is invalid");
|
715
727
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED))
|
716
|
-
git_error_set(
|
728
|
+
git_error_set(GIT_ERROR_HTTP, "certificate revocation check failed");
|
717
729
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED))
|
718
|
-
git_error_set(
|
730
|
+
git_error_set(GIT_ERROR_HTTP, "SSL certificate was revoked");
|
719
731
|
else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR))
|
720
|
-
git_error_set(
|
732
|
+
git_error_set(GIT_ERROR_HTTP, "security libraries could not be loaded");
|
721
733
|
else
|
722
|
-
git_error_set(
|
734
|
+
git_error_set(GIT_ERROR_HTTP, "unknown security error %lu", status);
|
723
735
|
}
|
724
736
|
|
725
737
|
static int winhttp_connect(
|
@@ -735,18 +747,19 @@ static int winhttp_connect(
|
|
735
747
|
DWORD protocols =
|
736
748
|
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
|
737
749
|
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
|
738
|
-
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
|
750
|
+
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 |
|
751
|
+
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3;
|
739
752
|
|
740
753
|
t->session = NULL;
|
741
754
|
t->connection = NULL;
|
742
755
|
|
743
756
|
/* Prepare port */
|
744
|
-
if (git__strntol32(&port, t->
|
745
|
-
strlen(t->
|
757
|
+
if (git__strntol32(&port, t->server.url.port,
|
758
|
+
strlen(t->server.url.port), NULL, 10) < 0)
|
746
759
|
return -1;
|
747
760
|
|
748
761
|
/* Prepare host */
|
749
|
-
if (git__utf8_to_16_alloc(&wide_host, t->
|
762
|
+
if (git__utf8_to_16_alloc(&wide_host, t->server.url.host) < 0) {
|
750
763
|
git_error_set(GIT_ERROR_OS, "unable to convert host to wide characters");
|
751
764
|
return -1;
|
752
765
|
}
|
@@ -780,14 +793,20 @@ static int winhttp_connect(
|
|
780
793
|
}
|
781
794
|
|
782
795
|
/*
|
783
|
-
* Do a best-effort attempt to enable TLS 1.2 but allow this to
|
784
|
-
* fail; if TLS 1.2 support is not available for some reason,
|
796
|
+
* Do a best-effort attempt to enable TLS 1.3 and 1.2 but allow this to
|
797
|
+
* fail; if TLS 1.2 or 1.3 support is not available for some reason,
|
785
798
|
* ignore the failure (it will keep the default protocols).
|
786
799
|
*/
|
787
|
-
WinHttpSetOption(t->session,
|
800
|
+
if (WinHttpSetOption(t->session,
|
788
801
|
WINHTTP_OPTION_SECURE_PROTOCOLS,
|
789
802
|
&protocols,
|
790
|
-
sizeof(protocols))
|
803
|
+
sizeof(protocols)) == FALSE) {
|
804
|
+
protocols &= ~WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3;
|
805
|
+
WinHttpSetOption(t->session,
|
806
|
+
WINHTTP_OPTION_SECURE_PROTOCOLS,
|
807
|
+
&protocols,
|
808
|
+
sizeof(protocols));
|
809
|
+
}
|
791
810
|
|
792
811
|
if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
|
793
812
|
git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP");
|
@@ -824,13 +843,18 @@ on_error:
|
|
824
843
|
return error;
|
825
844
|
}
|
826
845
|
|
827
|
-
static int do_send_request(winhttp_stream *s, size_t len,
|
846
|
+
static int do_send_request(winhttp_stream *s, size_t len, bool chunked)
|
828
847
|
{
|
829
848
|
int attempts;
|
830
849
|
bool success;
|
831
850
|
|
851
|
+
if (len > DWORD_MAX) {
|
852
|
+
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
853
|
+
return -1;
|
854
|
+
}
|
855
|
+
|
832
856
|
for (attempts = 0; attempts < 5; attempts++) {
|
833
|
-
if (
|
857
|
+
if (chunked) {
|
834
858
|
success = WinHttpSendRequest(s->request,
|
835
859
|
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
|
836
860
|
WINHTTP_NO_REQUEST_DATA, 0,
|
@@ -839,7 +863,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
|
|
839
863
|
success = WinHttpSendRequest(s->request,
|
840
864
|
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
|
841
865
|
WINHTTP_NO_REQUEST_DATA, 0,
|
842
|
-
len, 0);
|
866
|
+
(DWORD)len, 0);
|
843
867
|
}
|
844
868
|
|
845
869
|
if (success || GetLastError() != (DWORD)SEC_E_BUFFER_TOO_SMALL)
|
@@ -849,13 +873,13 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
|
|
849
873
|
return success ? 0 : -1;
|
850
874
|
}
|
851
875
|
|
852
|
-
static int send_request(winhttp_stream *s, size_t len,
|
876
|
+
static int send_request(winhttp_stream *s, size_t len, bool chunked)
|
853
877
|
{
|
854
878
|
int request_failed = 0, cert_valid = 1, error = 0;
|
855
879
|
DWORD ignore_flags;
|
856
880
|
|
857
881
|
git_error_clear();
|
858
|
-
if ((error = do_send_request(s, len,
|
882
|
+
if ((error = do_send_request(s, len, chunked)) < 0) {
|
859
883
|
if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) {
|
860
884
|
git_error_set(GIT_ERROR_OS, "failed to send request");
|
861
885
|
return -1;
|
@@ -884,12 +908,65 @@ static int send_request(winhttp_stream *s, size_t len, int ignore_length)
|
|
884
908
|
return -1;
|
885
909
|
}
|
886
910
|
|
887
|
-
if ((error = do_send_request(s, len,
|
911
|
+
if ((error = do_send_request(s, len, chunked)) < 0)
|
888
912
|
git_error_set(GIT_ERROR_OS, "failed to send request with unchecked certificate");
|
889
913
|
|
890
914
|
return error;
|
891
915
|
}
|
892
916
|
|
917
|
+
static int acquire_credentials(
|
918
|
+
HINTERNET request,
|
919
|
+
winhttp_server *server,
|
920
|
+
const char *url_str,
|
921
|
+
git_credential_acquire_cb cred_cb,
|
922
|
+
void *cred_cb_payload)
|
923
|
+
{
|
924
|
+
int allowed_types;
|
925
|
+
int error = 1;
|
926
|
+
|
927
|
+
if (parse_unauthorized_response(&allowed_types, &server->auth_mechanisms, request) < 0)
|
928
|
+
return -1;
|
929
|
+
|
930
|
+
if (allowed_types) {
|
931
|
+
git_credential_free(server->cred);
|
932
|
+
server->cred = NULL;
|
933
|
+
|
934
|
+
/* Start with URL-specified credentials, if there were any. */
|
935
|
+
if (!server->url_cred_presented && server->url.username && server->url.password) {
|
936
|
+
error = acquire_url_cred(&server->cred, allowed_types, server->url.username, server->url.password);
|
937
|
+
server->url_cred_presented = 1;
|
938
|
+
|
939
|
+
if (error < 0)
|
940
|
+
return error;
|
941
|
+
}
|
942
|
+
|
943
|
+
/* Next use the user-defined callback, if there is one. */
|
944
|
+
if (error > 0 && cred_cb) {
|
945
|
+
error = cred_cb(&server->cred, url_str, server->url.username, allowed_types, cred_cb_payload);
|
946
|
+
|
947
|
+
/* Treat GIT_PASSTHROUGH as though git_credential_acquire_cb isn't set */
|
948
|
+
if (error == GIT_PASSTHROUGH)
|
949
|
+
error = 1;
|
950
|
+
else if (error < 0)
|
951
|
+
return error;
|
952
|
+
}
|
953
|
+
|
954
|
+
/* Finally, invoke the fallback default credential lookup. */
|
955
|
+
if (error > 0) {
|
956
|
+
error = acquire_fallback_cred(&server->cred, url_str, allowed_types);
|
957
|
+
|
958
|
+
if (error < 0)
|
959
|
+
return error;
|
960
|
+
}
|
961
|
+
}
|
962
|
+
|
963
|
+
/*
|
964
|
+
* No error occurred but we could not find appropriate credentials.
|
965
|
+
* This behaves like a pass-through.
|
966
|
+
*/
|
967
|
+
return error;
|
968
|
+
}
|
969
|
+
|
893
970
|
static int winhttp_stream_read(
|
894
971
|
git_smart_subtransport_stream *stream,
|
895
972
|
char *buffer,
|
@@ -905,7 +982,7 @@ static int winhttp_stream_read(
|
|
905
982
|
replay:
|
906
983
|
/* Enforce a reasonable cap on the number of replays */
|
907
984
|
if (replay_count++ >= GIT_HTTP_REPLAY_MAX) {
|
908
|
-
git_error_set(
|
985
|
+
git_error_set(GIT_ERROR_HTTP, "too many redirects or authentication replays");
|
909
986
|
return -1;
|
910
987
|
}
|
911
988
|
|
@@ -920,7 +997,7 @@ replay:
|
|
920
997
|
|
921
998
|
if (!s->sent_request) {
|
922
999
|
|
923
|
-
if ((error = send_request(s, s->post_body_len,
|
1000
|
+
if ((error = send_request(s, s->post_body_len, false)) < 0)
|
924
1001
|
return error;
|
925
1002
|
|
926
1003
|
s->sent_request = 1;
|
@@ -956,6 +1033,7 @@ replay:
|
|
956
1033
|
}
|
957
1034
|
|
958
1035
|
buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE);
|
1036
|
+
GIT_ERROR_CHECK_ALLOC(buffer);
|
959
1037
|
|
960
1038
|
while (len > 0) {
|
961
1039
|
DWORD bytes_written;
|
@@ -1014,7 +1092,8 @@ replay:
|
|
1014
1092
|
HTTP_STATUS_REDIRECT == status_code ||
|
1015
1093
|
(HTTP_STATUS_REDIRECT_METHOD == status_code &&
|
1016
1094
|
get_verb == s->verb) ||
|
1017
|
-
HTTP_STATUS_REDIRECT_KEEP_VERB == status_code
|
1095
|
+
HTTP_STATUS_REDIRECT_KEEP_VERB == status_code ||
|
1096
|
+
HTTP_STATUS_PERMANENT_REDIRECT == status_code)) {
|
1018
1097
|
|
1019
1098
|
/* Check for Windows 7. This workaround is only necessary on
|
1020
1099
|
* Windows Vista and earlier. Windows 7 is version 6.1. */
|
@@ -1062,7 +1141,7 @@ replay:
|
|
1062
1141
|
|
1063
1142
|
if (!git__prefixcmp_icase(location8, prefix_https)) {
|
1064
1143
|
/* Upgrade to secure connection; disconnect and start over */
|
1065
|
-
if (
|
1144
|
+
if (git_net_url_apply_redirect(&t->server.url, location8, s->service_url) < 0) {
|
1066
1145
|
git__free(location8);
|
1067
1146
|
return -1;
|
1068
1147
|
}
|
@@ -1077,72 +1156,39 @@ replay:
|
|
1077
1156
|
goto replay;
|
1078
1157
|
}
|
1079
1158
|
|
1080
|
-
/* Handle proxy authentication failures */
|
1081
|
-
if (status_code == HTTP_STATUS_PROXY_AUTH_REQ) {
|
1082
|
-
int allowed_types;
|
1083
|
-
|
1084
|
-
if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanisms) < 0)
|
1085
|
-
return -1;
|
1086
|
-
|
1087
|
-
/* TODO: extract the username from the url, no payload? */
|
1088
|
-
if (t->owner->proxy.credentials) {
|
1089
|
-
int cred_error = 1;
|
1090
|
-
cred_error = t->owner->proxy.credentials(&t->proxy_cred, t->owner->proxy.url, NULL, allowed_types, t->owner->proxy.payload);
|
1091
|
-
|
1092
|
-
if (cred_error < 0)
|
1093
|
-
return cred_error;
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
winhttp_stream_close(s);
|
1097
|
-
goto replay;
|
1098
|
-
}
|
1099
|
-
|
1100
1159
|
/* Handle authentication failures */
|
1101
|
-
if (
|
1102
|
-
int
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
t->cred
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
if (cred_error < 0)
|
1130
|
-
return cred_error;
|
1131
|
-
}
|
1132
|
-
|
1133
|
-
if (!cred_error) {
|
1134
|
-
assert(t->cred);
|
1135
|
-
|
1136
|
-
winhttp_stream_close(s);
|
1137
|
-
|
1138
|
-
/* Successfully acquired a credential */
|
1139
|
-
goto replay;
|
1140
|
-
}
|
1160
|
+
if (status_code == HTTP_STATUS_DENIED) {
|
1161
|
+
int error = acquire_credentials(s->request,
|
1162
|
+
&t->server,
|
1163
|
+
t->owner->url,
|
1164
|
+
t->owner->cred_acquire_cb,
|
1165
|
+
t->owner->cred_acquire_payload);
|
1166
|
+
|
1167
|
+
if (error < 0) {
|
1168
|
+
return error;
|
1169
|
+
} else if (!error) {
|
1170
|
+
assert(t->server.cred);
|
1171
|
+
winhttp_stream_close(s);
|
1172
|
+
goto replay;
|
1173
|
+
}
|
1174
|
+
} else if (status_code == HTTP_STATUS_PROXY_AUTH_REQ) {
|
1175
|
+
int error = acquire_credentials(s->request,
|
1176
|
+
&t->proxy,
|
1177
|
+
t->owner->proxy.url,
|
1178
|
+
t->owner->proxy.credentials,
|
1179
|
+
t->owner->proxy.payload);
|
1180
|
+
|
1181
|
+
if (error < 0) {
|
1182
|
+
return error;
|
1183
|
+
} else if (!error) {
|
1184
|
+
assert(t->proxy.cred);
|
1185
|
+
winhttp_stream_close(s);
|
1186
|
+
goto replay;
|
1141
1187
|
}
|
1142
1188
|
}
|
1143
1189
|
|
1144
1190
|
if (HTTP_STATUS_OK != status_code) {
|
1145
|
-
git_error_set(
|
1191
|
+
git_error_set(GIT_ERROR_HTTP, "request failed with status code: %lu", status_code);
|
1146
1192
|
return -1;
|
1147
1193
|
}
|
1148
1194
|
|
@@ -1169,7 +1215,7 @@ replay:
|
|
1169
1215
|
}
|
1170
1216
|
|
1171
1217
|
if (wcscmp(expected_content_type, content_type)) {
|
1172
|
-
git_error_set(
|
1218
|
+
git_error_set(GIT_ERROR_HTTP, "received unexpected content-type");
|
1173
1219
|
return -1;
|
1174
1220
|
}
|
1175
1221
|
|
@@ -1204,11 +1250,11 @@ static int winhttp_stream_write_single(
|
|
1204
1250
|
|
1205
1251
|
/* This implementation of write permits only a single call. */
|
1206
1252
|
if (s->sent_request) {
|
1207
|
-
git_error_set(
|
1253
|
+
git_error_set(GIT_ERROR_HTTP, "subtransport configured for only one write");
|
1208
1254
|
return -1;
|
1209
1255
|
}
|
1210
1256
|
|
1211
|
-
if ((error = send_request(s, len,
|
1257
|
+
if ((error = send_request(s, len, false)) < 0)
|
1212
1258
|
return error;
|
1213
1259
|
|
1214
1260
|
s->sent_request = 1;
|
@@ -1235,12 +1281,12 @@ static int put_uuid_string(LPWSTR buffer, size_t buffer_len_cch)
|
|
1235
1281
|
if (RPC_S_OK != status &&
|
1236
1282
|
RPC_S_UUID_LOCAL_ONLY != status &&
|
1237
1283
|
RPC_S_UUID_NO_ADDRESS != status) {
|
1238
|
-
git_error_set(
|
1284
|
+
git_error_set(GIT_ERROR_HTTP, "unable to generate name for temp file");
|
1239
1285
|
return -1;
|
1240
1286
|
}
|
1241
1287
|
|
1242
1288
|
if (buffer_len_cch < UUID_LENGTH_CCH + 1) {
|
1243
|
-
git_error_set(
|
1289
|
+
git_error_set(GIT_ERROR_HTTP, "buffer too small for name of temp file");
|
1244
1290
|
return -1;
|
1245
1291
|
}
|
1246
1292
|
|
@@ -1347,7 +1393,7 @@ static int winhttp_stream_write_chunked(
|
|
1347
1393
|
return -1;
|
1348
1394
|
}
|
1349
1395
|
|
1350
|
-
if ((error = send_request(s, 0,
|
1396
|
+
if ((error = send_request(s, 0, true)) < 0)
|
1351
1397
|
return error;
|
1352
1398
|
|
1353
1399
|
s->sent_request = 1;
|
@@ -1370,8 +1416,10 @@ static int winhttp_stream_write_chunked(
|
|
1370
1416
|
/* Append as much to the buffer as we can */
|
1371
1417
|
int count = (int)min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len);
|
1372
1418
|
|
1373
|
-
if (!s->chunk_buffer)
|
1419
|
+
if (!s->chunk_buffer) {
|
1374
1420
|
s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE);
|
1421
|
+
GIT_ERROR_CHECK_ALLOC(s->chunk_buffer);
|
1422
|
+
}
|
1375
1423
|
|
1376
1424
|
memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count);
|
1377
1425
|
s->chunk_buffer_len += count;
|
@@ -1496,7 +1544,7 @@ static int winhttp_action(
|
|
1496
1544
|
int ret = -1;
|
1497
1545
|
|
1498
1546
|
if (!t->connection)
|
1499
|
-
if ((ret =
|
1547
|
+
if ((ret = git_net_url_parse(&t->server.url, url)) < 0 ||
|
1500
1548
|
(ret = winhttp_connect(t)) < 0)
|
1501
1549
|
return ret;
|
1502
1550
|
|
@@ -1538,24 +1586,17 @@ static int winhttp_close(git_smart_subtransport *subtransport)
|
|
1538
1586
|
{
|
1539
1587
|
winhttp_subtransport *t = (winhttp_subtransport *)subtransport;
|
1540
1588
|
|
1541
|
-
|
1542
|
-
|
1543
|
-
gitno_connection_data_free_ptrs(&t->proxy_connection_data);
|
1544
|
-
memset(&t->proxy_connection_data, 0x0, sizeof(gitno_connection_data));
|
1545
|
-
|
1546
|
-
if (t->cred) {
|
1547
|
-
t->cred->free(t->cred);
|
1548
|
-
t->cred = NULL;
|
1549
|
-
}
|
1589
|
+
git_net_url_dispose(&t->server.url);
|
1590
|
+
git_net_url_dispose(&t->proxy.url);
|
1550
1591
|
|
1551
|
-
if (t->
|
1552
|
-
t->
|
1553
|
-
t->
|
1592
|
+
if (t->server.cred) {
|
1593
|
+
t->server.cred->free(t->server.cred);
|
1594
|
+
t->server.cred = NULL;
|
1554
1595
|
}
|
1555
1596
|
|
1556
|
-
if (t->
|
1557
|
-
t->
|
1558
|
-
t->
|
1597
|
+
if (t->proxy.cred) {
|
1598
|
+
t->proxy.cred->free(t->proxy.cred);
|
1599
|
+
t->proxy.cred = NULL;
|
1559
1600
|
}
|
1560
1601
|
|
1561
1602
|
return winhttp_close_connection(t);
|