rugged 1.9.0 → 1.9.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +4 -4
- data/ext/rugged/rugged.c +12 -1
- data/ext/rugged/rugged_blame.c +22 -6
- data/ext/rugged/rugged_blob.c +24 -9
- data/ext/rugged/rugged_branch.c +10 -7
- data/ext/rugged/rugged_branch_collection.c +8 -6
- data/ext/rugged/rugged_commit.c +7 -6
- data/ext/rugged/rugged_config.c +20 -11
- data/ext/rugged/rugged_diff.c +26 -12
- data/ext/rugged/rugged_diff_hunk.c +2 -1
- data/ext/rugged/rugged_index.c +39 -29
- data/ext/rugged/rugged_note.c +7 -6
- data/ext/rugged/rugged_object.c +3 -2
- data/ext/rugged/rugged_patch.c +23 -9
- data/ext/rugged/rugged_rebase.c +22 -10
- data/ext/rugged/rugged_reference.c +22 -13
- data/ext/rugged/rugged_reference_collection.c +9 -7
- data/ext/rugged/rugged_remote.c +23 -12
- data/ext/rugged/rugged_remote_collection.c +11 -9
- data/ext/rugged/rugged_repo.c +60 -45
- data/ext/rugged/rugged_revwalk.c +22 -12
- data/ext/rugged/rugged_submodule.c +23 -20
- data/ext/rugged/rugged_submodule_collection.c +20 -9
- data/ext/rugged/rugged_tag.c +6 -4
- data/ext/rugged/rugged_tag_collection.c +7 -5
- data/ext/rugged/rugged_tree.c +27 -15
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +2 -0
- data/vendor/libgit2/CMakeLists.txt +1 -1
- data/vendor/libgit2/COPYING +83 -11
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +4 -1
- data/vendor/libgit2/cmake/SelectRegex.cmake +8 -3
- data/vendor/libgit2/cmake/SelectSSH.cmake +9 -3
- data/vendor/libgit2/deps/pcre2/CMakeLists.txt +110 -0
- data/vendor/libgit2/deps/pcre2/LICENCE.md +104 -0
- data/vendor/libgit2/deps/pcre2/config.h.in +54 -0
- data/vendor/libgit2/deps/pcre2/pcre2.h +1079 -0
- data/vendor/libgit2/deps/pcre2/pcre2_auto_possess.c +1416 -0
- data/vendor/libgit2/deps/{pcre/pcre_chartables.c → pcre2/pcre2_chartables.c} +41 -47
- data/vendor/libgit2/deps/{pcre/pcre_ord2utf8.c → pcre2/pcre2_chkdint.c} +36 -36
- data/vendor/libgit2/deps/pcre2/pcre2_compile.c +11345 -0
- data/vendor/libgit2/deps/pcre2/pcre2_compile.h +356 -0
- data/vendor/libgit2/deps/pcre2/pcre2_compile_cgroup.c +632 -0
- data/vendor/libgit2/deps/pcre2/pcre2_compile_class.c +2777 -0
- data/vendor/libgit2/deps/pcre2/pcre2_config.c +250 -0
- data/vendor/libgit2/deps/pcre2/pcre2_context.c +557 -0
- data/vendor/libgit2/deps/pcre2/pcre2_convert.c +1263 -0
- data/vendor/libgit2/deps/{pcre/pcre_dfa_exec.c → pcre2/pcre2_dfa_match.c} +1402 -943
- data/vendor/libgit2/deps/pcre2/pcre2_error.c +384 -0
- data/vendor/libgit2/deps/pcre2/pcre2_extuni.c +159 -0
- data/vendor/libgit2/deps/pcre2/pcre2_find_bracket.c +217 -0
- data/vendor/libgit2/deps/pcre2/pcre2_fuzzsupport.c +844 -0
- data/vendor/libgit2/deps/pcre2/pcre2_internal.h +2353 -0
- data/vendor/libgit2/deps/pcre2/pcre2_intmodedep.h +1044 -0
- data/vendor/libgit2/deps/pcre2/pcre2_maketables.c +177 -0
- data/vendor/libgit2/deps/pcre2/pcre2_match.c +8244 -0
- data/vendor/libgit2/deps/pcre2/pcre2_match_data.c +184 -0
- data/vendor/libgit2/deps/pcre2/pcre2_match_next.c +171 -0
- data/vendor/libgit2/deps/{pcre/pcre_newline.c → pcre2/pcre2_newline.c} +92 -63
- data/vendor/libgit2/deps/{pcre/pcre_refcount.c → pcre2/pcre2_ord2utf.c} +64 -38
- data/vendor/libgit2/deps/pcre2/pcre2_pattern_info.c +430 -0
- data/vendor/libgit2/deps/pcre2/pcre2_printint_inc.h +1098 -0
- data/vendor/libgit2/deps/pcre2/pcre2_script_run.c +344 -0
- data/vendor/libgit2/deps/pcre2/pcre2_serialize.c +284 -0
- data/vendor/libgit2/deps/pcre2/pcre2_string_utils.c +199 -0
- data/vendor/libgit2/deps/pcre2/pcre2_study.c +2087 -0
- data/vendor/libgit2/deps/pcre2/pcre2_substitute.c +1761 -0
- data/vendor/libgit2/deps/pcre2/pcre2_substring.c +553 -0
- data/vendor/libgit2/deps/pcre2/pcre2_tables.c +310 -0
- data/vendor/libgit2/deps/pcre2/pcre2_ucd.c +5805 -0
- data/vendor/libgit2/deps/pcre2/pcre2_ucp.h +408 -0
- data/vendor/libgit2/deps/pcre2/pcre2_ucptables_inc.h +1596 -0
- data/vendor/libgit2/deps/pcre2/pcre2_util.h +179 -0
- data/vendor/libgit2/deps/pcre2/pcre2_valid_utf.c +397 -0
- data/vendor/libgit2/deps/pcre2/pcre2_xclass.c +547 -0
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +1 -1
- data/vendor/libgit2/deps/xdiff/xmerge.c +14 -10
- data/vendor/libgit2/include/git2/common.h +13 -1
- data/vendor/libgit2/include/git2/deprecated.h +1 -1
- data/vendor/libgit2/include/git2/index.h +1 -1
- data/vendor/libgit2/include/git2/merge.h +4 -2
- data/vendor/libgit2/include/git2/oid.h +0 -1
- data/vendor/libgit2/include/git2/proxy.h +2 -3
- data/vendor/libgit2/include/git2/remote.h +19 -7
- data/vendor/libgit2/include/git2/stdint.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +1 -1
- data/vendor/libgit2/include/git2/version.h +4 -2
- data/vendor/libgit2/src/cli/CMakeLists.txt +1 -2
- data/vendor/libgit2/src/cli/opt.c +3 -3
- data/vendor/libgit2/src/cli/opt_usage.c +1 -1
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +32 -16
- data/vendor/libgit2/src/libgit2/attr_file.c +10 -3
- data/vendor/libgit2/src/libgit2/blame.c +6 -0
- data/vendor/libgit2/src/libgit2/clone.c +6 -0
- data/vendor/libgit2/src/libgit2/commit.c +1 -1
- data/vendor/libgit2/src/libgit2/commit_graph.c +1 -2
- data/vendor/libgit2/src/libgit2/config.c +1 -1
- data/vendor/libgit2/src/libgit2/config_file.c +2 -1
- data/vendor/libgit2/src/libgit2/config_mem.c +1 -0
- data/vendor/libgit2/src/libgit2/config_parse.c +2 -1
- data/vendor/libgit2/src/libgit2/delta.c +13 -1
- data/vendor/libgit2/src/libgit2/diff_driver.c +1 -1
- data/vendor/libgit2/src/libgit2/diff_stats.c +19 -12
- data/vendor/libgit2/src/libgit2/fetchhead.c +1 -1
- data/vendor/libgit2/src/libgit2/index.c +8 -8
- data/vendor/libgit2/src/libgit2/index.h +3 -0
- data/vendor/libgit2/src/libgit2/indexer.c +5 -4
- data/vendor/libgit2/src/libgit2/merge.c +1 -1
- data/vendor/libgit2/src/libgit2/merge.h +4 -0
- data/vendor/libgit2/src/libgit2/merge_file.c +43 -30
- data/vendor/libgit2/src/libgit2/message.c +1 -1
- data/vendor/libgit2/src/libgit2/midx.c +2 -3
- data/vendor/libgit2/src/libgit2/odb.c +2 -6
- data/vendor/libgit2/src/libgit2/odb_loose.c +24 -14
- data/vendor/libgit2/src/libgit2/oid.c +4 -5
- data/vendor/libgit2/src/libgit2/pack-objects.c +2 -4
- data/vendor/libgit2/src/libgit2/pack.c +3 -0
- data/vendor/libgit2/src/libgit2/refs.c +15 -6
- data/vendor/libgit2/src/libgit2/remote.c +4 -1
- data/vendor/libgit2/src/libgit2/remote.h +0 -1
- data/vendor/libgit2/src/libgit2/repository.c +5 -4
- data/vendor/libgit2/src/libgit2/settings.c +9 -0
- data/vendor/libgit2/src/libgit2/streams/openssl.c +4 -1
- data/vendor/libgit2/src/libgit2/streams/socket.c +30 -0
- data/vendor/libgit2/src/libgit2/submodule.c +89 -17
- data/vendor/libgit2/src/libgit2/tag.c +3 -1
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +2 -0
- data/vendor/libgit2/src/libgit2/transports/credential.c +1 -1
- data/vendor/libgit2/src/libgit2/transports/git.c +1 -1
- data/vendor/libgit2/src/libgit2/transports/http.c +4 -4
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +12 -9
- data/vendor/libgit2/src/libgit2/transports/local.c +8 -1
- data/vendor/libgit2/src/libgit2/transports/smart.c +5 -5
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +5 -4
- data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +57 -18
- data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.c +3 -3
- data/vendor/libgit2/src/util/CMakeLists.txt +3 -4
- data/vendor/libgit2/src/util/fs_path.c +66 -6
- data/vendor/libgit2/src/util/fs_path.h +16 -10
- data/vendor/libgit2/src/util/futils.h +11 -3
- data/vendor/libgit2/src/util/hash/builtin.c +14 -4
- data/vendor/libgit2/src/util/hash/openssl.c +0 -4
- data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +8 -6
- data/vendor/libgit2/src/util/hashmap.h +1 -0
- data/vendor/libgit2/src/util/net.c +5 -5
- data/vendor/libgit2/src/util/process.h +2 -1
- data/vendor/libgit2/src/util/regexp.c +27 -12
- data/vendor/libgit2/src/util/regexp.h +7 -2
- data/vendor/libgit2/src/util/runtime.c +2 -2
- data/vendor/libgit2/src/util/str.c +18 -6
- data/vendor/libgit2/src/util/str.h +5 -3
- data/vendor/libgit2/src/util/unix/process.c +92 -15
- data/vendor/libgit2/src/util/util.c +16 -3
- data/vendor/libgit2/src/util/util.h +1 -0
- data/vendor/libgit2/src/util/win32/path_w32.c +81 -5
- data/vendor/libgit2/src/util/win32/process.c +22 -6
- metadata +59 -41
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -141
- data/vendor/libgit2/deps/pcre/COPYING +0 -5
- data/vendor/libgit2/deps/pcre/LICENCE +0 -93
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
- data/vendor/libgit2/deps/pcre/config.h.in +0 -57
- data/vendor/libgit2/deps/pcre/pcre.h +0 -641
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
- data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9815
- data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
- data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
- data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
- data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
- data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
- data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
- data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
- data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
- data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
- data/vendor/libgit2/deps/pcre/pcreposix.c +0 -420
- data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
- data/vendor/libgit2/deps/pcre/ucp.h +0 -224
|
@@ -611,6 +611,37 @@ bool git_fs_path_isfile(const char *path)
|
|
|
611
611
|
return S_ISREG(st.st_mode) != 0;
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
+
#ifdef GIT_WIN32
|
|
615
|
+
|
|
616
|
+
bool git_fs_path_isexecutable(const char *path)
|
|
617
|
+
{
|
|
618
|
+
struct stat st;
|
|
619
|
+
|
|
620
|
+
GIT_ASSERT_ARG_WITH_RETVAL(path, false);
|
|
621
|
+
|
|
622
|
+
if (git__suffixcmp_icase(path, ".exe") != 0 &&
|
|
623
|
+
git__suffixcmp_icase(path, ".cmd") != 0)
|
|
624
|
+
return false;
|
|
625
|
+
|
|
626
|
+
return (p_stat(path, &st) == 0);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
#else
|
|
630
|
+
|
|
631
|
+
bool git_fs_path_isexecutable(const char *path)
|
|
632
|
+
{
|
|
633
|
+
struct stat st;
|
|
634
|
+
|
|
635
|
+
GIT_ASSERT_ARG_WITH_RETVAL(path, false);
|
|
636
|
+
if (p_stat(path, &st) < 0)
|
|
637
|
+
return false;
|
|
638
|
+
|
|
639
|
+
return S_ISREG(st.st_mode) != 0 &&
|
|
640
|
+
((st.st_mode & S_IXUSR) != 0);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
#endif
|
|
644
|
+
|
|
614
645
|
bool git_fs_path_islink(const char *path)
|
|
615
646
|
{
|
|
616
647
|
struct stat st;
|
|
@@ -2020,9 +2051,10 @@ int git_fs_path_owner_is_system(bool *out, const char *path)
|
|
|
2020
2051
|
return git_fs_path_owner_is(out, path, GIT_FS_PATH_OWNER_ADMINISTRATOR);
|
|
2021
2052
|
}
|
|
2022
2053
|
|
|
2023
|
-
int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
2024
|
-
{
|
|
2025
2054
|
#ifdef GIT_WIN32
|
|
2055
|
+
|
|
2056
|
+
static int find_executable(git_str *fullpath, const char *executable)
|
|
2057
|
+
{
|
|
2026
2058
|
git_win32_path fullpath_w, executable_w;
|
|
2027
2059
|
int error;
|
|
2028
2060
|
|
|
@@ -2035,9 +2067,15 @@ int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
|
2035
2067
|
error = git_str_put_w(fullpath, fullpath_w, wcslen(fullpath_w));
|
|
2036
2068
|
|
|
2037
2069
|
return error;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2038
2072
|
#else
|
|
2073
|
+
|
|
2074
|
+
static int find_executable(git_str *fullpath, const char *executable)
|
|
2075
|
+
{
|
|
2039
2076
|
git_str path = GIT_STR_INIT;
|
|
2040
2077
|
const char *current_dir, *term;
|
|
2078
|
+
size_t current_dirlen;
|
|
2041
2079
|
bool found = false;
|
|
2042
2080
|
|
|
2043
2081
|
if (git__getenv(&path, "PATH") < 0)
|
|
@@ -2049,20 +2087,28 @@ int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
|
2049
2087
|
if (! (term = strchr(current_dir, GIT_PATH_LIST_SEPARATOR)))
|
|
2050
2088
|
term = strchr(current_dir, '\0');
|
|
2051
2089
|
|
|
2090
|
+
current_dirlen = term - current_dir;
|
|
2052
2091
|
git_str_clear(fullpath);
|
|
2053
|
-
|
|
2054
|
-
|
|
2092
|
+
|
|
2093
|
+
/* An empty path segment is treated as '.' */
|
|
2094
|
+
if (current_dirlen == 0 && git_str_putc(fullpath, '.'))
|
|
2095
|
+
return -1;
|
|
2096
|
+
else if (current_dirlen != 0 &&
|
|
2097
|
+
git_str_put(fullpath, current_dir, current_dirlen) < 0)
|
|
2098
|
+
return -1;
|
|
2099
|
+
|
|
2100
|
+
if (git_str_putc(fullpath, '/') < 0 ||
|
|
2055
2101
|
git_str_puts(fullpath, executable) < 0)
|
|
2056
2102
|
return -1;
|
|
2057
2103
|
|
|
2058
|
-
if (
|
|
2104
|
+
if (git_fs_path_isexecutable(fullpath->ptr)) {
|
|
2059
2105
|
found = true;
|
|
2060
2106
|
break;
|
|
2061
2107
|
}
|
|
2062
2108
|
|
|
2063
2109
|
current_dir = term;
|
|
2064
2110
|
|
|
2065
|
-
|
|
2111
|
+
if (*current_dir == GIT_PATH_LIST_SEPARATOR)
|
|
2066
2112
|
current_dir++;
|
|
2067
2113
|
}
|
|
2068
2114
|
|
|
@@ -2073,5 +2119,19 @@ int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
|
2073
2119
|
|
|
2074
2120
|
git_str_clear(fullpath);
|
|
2075
2121
|
return GIT_ENOTFOUND;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2076
2124
|
#endif
|
|
2125
|
+
|
|
2126
|
+
int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
2127
|
+
{
|
|
2128
|
+
/* For qualified paths we do not look in PATH */
|
|
2129
|
+
if (strchr(executable, '/') != NULL) {
|
|
2130
|
+
if (!git_fs_path_isexecutable(executable))
|
|
2131
|
+
return GIT_ENOTFOUND;
|
|
2132
|
+
|
|
2133
|
+
return git_str_puts(fullpath, executable);
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
return find_executable(fullpath, executable);
|
|
2077
2137
|
}
|
|
@@ -204,6 +204,12 @@ extern bool git_fs_path_isdir(const char *path);
|
|
|
204
204
|
*/
|
|
205
205
|
extern bool git_fs_path_isfile(const char *path);
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Check if the given path points to an executable.
|
|
209
|
+
* @return true or false
|
|
210
|
+
*/
|
|
211
|
+
extern bool git_fs_path_isexecutable(const char *path);
|
|
212
|
+
|
|
207
213
|
/**
|
|
208
214
|
* Check if the given path points to a symbolic link.
|
|
209
215
|
* @return true or false
|
|
@@ -632,18 +638,18 @@ extern int git_fs_path_from_url_or_path(git_str *local_path_out, const char *url
|
|
|
632
638
|
*/
|
|
633
639
|
#ifdef GIT_WIN32
|
|
634
640
|
# define GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS \
|
|
635
|
-
GIT_FS_PATH_REJECT_EMPTY_COMPONENT | \
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
641
|
+
(GIT_FS_PATH_REJECT_EMPTY_COMPONENT | \
|
|
642
|
+
GIT_FS_PATH_REJECT_TRAVERSAL | \
|
|
643
|
+
GIT_FS_PATH_REJECT_BACKSLASH | \
|
|
644
|
+
GIT_FS_PATH_REJECT_TRAILING_DOT | \
|
|
645
|
+
GIT_FS_PATH_REJECT_TRAILING_SPACE | \
|
|
646
|
+
GIT_FS_PATH_REJECT_TRAILING_COLON | \
|
|
647
|
+
GIT_FS_PATH_REJECT_DOS_PATHS | \
|
|
648
|
+
GIT_FS_PATH_REJECT_NT_CHARS)
|
|
643
649
|
#else
|
|
644
650
|
# define GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS \
|
|
645
|
-
GIT_FS_PATH_REJECT_EMPTY_COMPONENT | \
|
|
646
|
-
|
|
651
|
+
(GIT_FS_PATH_REJECT_EMPTY_COMPONENT | \
|
|
652
|
+
GIT_FS_PATH_REJECT_TRAVERSAL)
|
|
647
653
|
#endif
|
|
648
654
|
|
|
649
655
|
/**
|
|
@@ -32,9 +32,17 @@ extern int git_futils_readbuffer_fd(git_str *obj, git_file fd, size_t len);
|
|
|
32
32
|
|
|
33
33
|
/* Additional constants for `git_futils_writebuffer`'s `open_flags`. We
|
|
34
34
|
* support these internally and they will be removed before the `open` call.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
*
|
|
36
|
+
* Not all platforms define O_FSYNC. Fall back to O_SYNC (the POSIX
|
|
37
|
+
* standard name; O_FSYNC is a non-standard alias) when available,
|
|
38
|
+
* otherwise use a sentinel value that won't collide with real open
|
|
39
|
+
* flags. Avoid (1 << 31) since left-shifting into the sign bit of
|
|
40
|
+
* a signed int is undefined behavior.
|
|
41
|
+
*/
|
|
42
|
+
#if !defined(O_FSYNC) && defined(O_SYNC)
|
|
43
|
+
# define O_FSYNC O_SYNC
|
|
44
|
+
#elif !defined(O_FSYNC)
|
|
45
|
+
# define O_FSYNC (1 << 30)
|
|
38
46
|
#endif
|
|
39
47
|
|
|
40
48
|
extern int git_futils_writebuffer(
|
|
@@ -32,13 +32,23 @@ int git_hash_sha256_init(git_hash_sha256_ctx *ctx)
|
|
|
32
32
|
return 0;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
int git_hash_sha256_update(git_hash_sha256_ctx *ctx, const void *
|
|
35
|
+
int git_hash_sha256_update(git_hash_sha256_ctx *ctx, const void *_data, size_t len)
|
|
36
36
|
{
|
|
37
|
+
const unsigned char *data = _data;
|
|
37
38
|
GIT_ASSERT_ARG(ctx);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
while (len > 0) {
|
|
41
|
+
unsigned int chunk = (len > UINT_MAX) ? UINT_MAX : (unsigned int)len;
|
|
42
|
+
|
|
43
|
+
if (SHA256Input(&ctx->c, data, chunk)) {
|
|
44
|
+
git_error_set(GIT_ERROR_SHA, "SHA256 error");
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
data += chunk;
|
|
49
|
+
len -= chunk;
|
|
41
50
|
}
|
|
51
|
+
|
|
42
52
|
return 0;
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -189,8 +189,6 @@ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
|
|
|
189
189
|
return -1;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
ctx->c = NULL;
|
|
193
|
-
|
|
194
192
|
return 0;
|
|
195
193
|
}
|
|
196
194
|
|
|
@@ -339,8 +337,6 @@ int git_hash_sha256_final(unsigned char *out, git_hash_sha256_ctx *ctx)
|
|
|
339
337
|
return -1;
|
|
340
338
|
}
|
|
341
339
|
|
|
342
|
-
ctx->c = NULL;
|
|
343
|
-
|
|
344
340
|
return 0;
|
|
345
341
|
}
|
|
346
342
|
|
|
@@ -83,12 +83,14 @@
|
|
|
83
83
|
* Add "length" to the length.
|
|
84
84
|
* Set Corrupted when overflow has occurred.
|
|
85
85
|
*/
|
|
86
|
-
static
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
static int SHA224_256AddLength(SHA256Context *context, unsigned int length)
|
|
87
|
+
{
|
|
88
|
+
uint32_t addTemp = context->Length_Low;
|
|
89
|
+
context->Length_Low += length;
|
|
90
|
+
if (context->Length_Low < addTemp && ++context->Length_High == 0)
|
|
91
|
+
context->Corrupted = shaInputTooLong;
|
|
92
|
+
return context->Corrupted;
|
|
93
|
+
}
|
|
92
94
|
|
|
93
95
|
/* Local Function Prototypes */
|
|
94
96
|
static int SHA224_256Reset(SHA256Context *context, uint32_t *H0);
|
|
@@ -184,8 +184,8 @@ static int url_parse_authority(
|
|
|
184
184
|
const char *authority,
|
|
185
185
|
size_t len)
|
|
186
186
|
{
|
|
187
|
-
const char *c, *hostport_end, *host_end = NULL,
|
|
188
|
-
*userpass_end, *user_end = NULL;
|
|
187
|
+
const char *c, *hostport_end = NULL, *host_end = NULL,
|
|
188
|
+
*userpass_end = NULL, *user_end = NULL;
|
|
189
189
|
|
|
190
190
|
enum {
|
|
191
191
|
HOSTPORT, HOST, IPV6, HOST_END, USERPASS, USER
|
|
@@ -464,7 +464,7 @@ done:
|
|
|
464
464
|
int git_net_url_parse(git_net_url *url, const char *given)
|
|
465
465
|
{
|
|
466
466
|
git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
|
|
467
|
-
const char *c, *authority, *path;
|
|
467
|
+
const char *c, *authority = NULL, *path = NULL;
|
|
468
468
|
size_t authority_len = 0, path_len = 0;
|
|
469
469
|
int error = 0;
|
|
470
470
|
|
|
@@ -574,7 +574,7 @@ int git_net_url_parse_http(
|
|
|
574
574
|
const char *given)
|
|
575
575
|
{
|
|
576
576
|
git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
|
|
577
|
-
const char *c, *authority, *path = NULL;
|
|
577
|
+
const char *c = NULL, *authority = NULL, *path = NULL;
|
|
578
578
|
size_t authority_len = 0, path_len = 0;
|
|
579
579
|
int error;
|
|
580
580
|
|
|
@@ -661,7 +661,7 @@ static bool has_at(const char *str)
|
|
|
661
661
|
int git_net_url_parse_scp(git_net_url *url, const char *given)
|
|
662
662
|
{
|
|
663
663
|
const char *default_port = default_port_for_scheme("ssh");
|
|
664
|
-
const char *c, *user, *host, *port = NULL, *path = NULL;
|
|
664
|
+
const char *c, *user = NULL, *host = NULL, *port = NULL, *path = NULL;
|
|
665
665
|
size_t user_len = 0, host_len = 0, port_len = 0;
|
|
666
666
|
unsigned short bracket = 0;
|
|
667
667
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include "regexp.h"
|
|
9
9
|
|
|
10
|
-
#if defined(
|
|
10
|
+
#if defined(GIT_REGEX_PCRE)
|
|
11
11
|
|
|
12
12
|
int git_regexp_compile(git_regexp *r, const char *pattern, int flags)
|
|
13
13
|
{
|
|
@@ -73,7 +73,7 @@ out:
|
|
|
73
73
|
return 0;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
#elif defined(GIT_REGEX_PCRE2)
|
|
76
|
+
#elif defined(GIT_REGEX_BUILTIN) || defined(GIT_REGEX_PCRE2)
|
|
77
77
|
|
|
78
78
|
int git_regexp_compile(git_regexp *r, const char *pattern, int flags)
|
|
79
79
|
{
|
|
@@ -84,8 +84,9 @@ int git_regexp_compile(git_regexp *r, const char *pattern, int flags)
|
|
|
84
84
|
if (flags & GIT_REGEXP_ICASE)
|
|
85
85
|
cflags |= PCRE2_CASELESS;
|
|
86
86
|
|
|
87
|
-
if ((*r = pcre2_compile((const unsigned char *) pattern,
|
|
88
|
-
|
|
87
|
+
if ((*r = pcre2_compile((const unsigned char *) pattern,
|
|
88
|
+
PCRE2_ZERO_TERMINATED,
|
|
89
|
+
cflags, &error, &erroff, NULL)) == NULL) {
|
|
89
90
|
pcre2_get_error_message(error, errmsg, sizeof(errmsg));
|
|
90
91
|
git_error_set_str(GIT_ERROR_REGEX, (char *) errmsg);
|
|
91
92
|
return GIT_EINVALIDSPEC;
|
|
@@ -110,37 +111,51 @@ int git_regexp_match(const git_regexp *r, const char *string)
|
|
|
110
111
|
|
|
111
112
|
error = pcre2_match(*r, (const unsigned char *) string, strlen(string), 0, 0, data, NULL);
|
|
112
113
|
pcre2_match_data_free(data);
|
|
114
|
+
|
|
113
115
|
if (error < 0)
|
|
114
116
|
return (error == PCRE2_ERROR_NOMATCH) ? GIT_ENOTFOUND : GIT_EINVALIDSPEC;
|
|
115
117
|
|
|
116
118
|
return 0;
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
int git_regexp_search(
|
|
121
|
+
int git_regexp_search(
|
|
122
|
+
const git_regexp *r,
|
|
123
|
+
const char *string,
|
|
124
|
+
size_t given_nmatches,
|
|
125
|
+
git_regmatch *matches)
|
|
120
126
|
{
|
|
121
127
|
pcre2_match_data *data = NULL;
|
|
122
128
|
PCRE2_SIZE *ovec;
|
|
129
|
+
size_t i, captures;
|
|
130
|
+
uint32_t nmatches;
|
|
123
131
|
int error;
|
|
124
|
-
|
|
132
|
+
|
|
133
|
+
GIT_ASSERT(given_nmatches <= UINT32_MAX);
|
|
134
|
+
|
|
135
|
+
nmatches = (uint32_t) given_nmatches;
|
|
125
136
|
|
|
126
137
|
if ((data = pcre2_match_data_create(nmatches, NULL)) == NULL) {
|
|
127
138
|
git_error_set_oom();
|
|
128
139
|
return -1;
|
|
129
140
|
}
|
|
130
141
|
|
|
131
|
-
if ((error = pcre2_match(*r, (const unsigned char *) string,
|
|
132
|
-
|
|
142
|
+
if ((error = pcre2_match(*r, (const unsigned char *) string,
|
|
143
|
+
strlen(string), 0, 0, data, NULL)) < 0)
|
|
133
144
|
goto out;
|
|
134
145
|
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
captures = (size_t) error;
|
|
147
|
+
|
|
148
|
+
if (!captures || captures > nmatches)
|
|
149
|
+
captures = nmatches;
|
|
150
|
+
|
|
137
151
|
ovec = pcre2_get_ovector_pointer(data);
|
|
138
152
|
|
|
139
|
-
for (i = 0; i <
|
|
153
|
+
for (i = 0; i < captures; i++) {
|
|
140
154
|
matches[i].start = (ovec[i * 2] == PCRE2_UNSET) ? -1 : (ssize_t) ovec[i * 2];
|
|
141
155
|
matches[i].end = (ovec[i * 2 + 1] == PCRE2_UNSET) ? -1 : (ssize_t) ovec[i * 2 + 1];
|
|
142
156
|
}
|
|
143
|
-
|
|
157
|
+
|
|
158
|
+
for (i = captures; i < nmatches; i++)
|
|
144
159
|
matches[i].start = matches[i].end = -1;
|
|
145
160
|
|
|
146
161
|
out:
|
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
#include "git2_util.h"
|
|
12
12
|
|
|
13
|
-
#if defined(GIT_REGEX_BUILTIN)
|
|
14
|
-
#
|
|
13
|
+
#if defined(GIT_REGEX_BUILTIN)
|
|
14
|
+
# define PCRE2_CODE_UNIT_WIDTH 8
|
|
15
|
+
# include "pcre2.h"
|
|
16
|
+
typedef pcre2_code *git_regexp;
|
|
17
|
+
# define GIT_REGEX_INIT NULL
|
|
18
|
+
#elif defined(GIT_REGEX_PCRE)
|
|
19
|
+
# include <pcre.h>
|
|
15
20
|
typedef pcre *git_regexp;
|
|
16
21
|
# define GIT_REGEX_INIT NULL
|
|
17
22
|
#elif defined(GIT_REGEX_PCRE2)
|
|
@@ -16,7 +16,7 @@ static git_atomic32 init_count;
|
|
|
16
16
|
static int init_common(git_runtime_init_fn init_fns[], size_t cnt)
|
|
17
17
|
{
|
|
18
18
|
size_t i;
|
|
19
|
-
int ret;
|
|
19
|
+
int ret = 0;
|
|
20
20
|
|
|
21
21
|
/* Initialize subsystems that have global state */
|
|
22
22
|
for (i = 0; i < cnt; i++) {
|
|
@@ -110,7 +110,7 @@ GIT_INLINE(int) init_unlock(void)
|
|
|
110
110
|
|
|
111
111
|
int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt)
|
|
112
112
|
{
|
|
113
|
-
int ret;
|
|
113
|
+
int ret = 0;
|
|
114
114
|
|
|
115
115
|
if (init_lock() < 0)
|
|
116
116
|
return -1;
|
|
@@ -1065,10 +1065,13 @@ int git_str_puts_escaped(
|
|
|
1065
1065
|
git_str *buf,
|
|
1066
1066
|
const char *string,
|
|
1067
1067
|
const char *esc_chars,
|
|
1068
|
-
const char *
|
|
1068
|
+
const char *esc_prefix,
|
|
1069
|
+
const char *esc_suffix)
|
|
1069
1070
|
{
|
|
1070
1071
|
const char *scan;
|
|
1071
|
-
size_t total = 0,
|
|
1072
|
+
size_t total = 0, count, alloclen;
|
|
1073
|
+
size_t esc_prefix_len = esc_prefix ? strlen(esc_prefix) : 0;
|
|
1074
|
+
size_t esc_suffix_len = esc_suffix ? strlen(esc_suffix) : 0;
|
|
1072
1075
|
|
|
1073
1076
|
if (!string)
|
|
1074
1077
|
return 0;
|
|
@@ -1080,7 +1083,7 @@ int git_str_puts_escaped(
|
|
|
1080
1083
|
scan += count;
|
|
1081
1084
|
/* count run of escaped characters */
|
|
1082
1085
|
count = strspn(scan, esc_chars);
|
|
1083
|
-
total += count * (
|
|
1086
|
+
total += count * (esc_prefix_len + esc_suffix_len + 1);
|
|
1084
1087
|
scan += count;
|
|
1085
1088
|
}
|
|
1086
1089
|
|
|
@@ -1096,13 +1099,22 @@ int git_str_puts_escaped(
|
|
|
1096
1099
|
buf->size += count;
|
|
1097
1100
|
|
|
1098
1101
|
for (count = strspn(scan, esc_chars); count > 0; --count) {
|
|
1099
|
-
/* copy escape sequence */
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
+
/* copy escape prefix sequence */
|
|
1103
|
+
if (esc_prefix) {
|
|
1104
|
+
memmove(buf->ptr + buf->size, esc_prefix, esc_prefix_len);
|
|
1105
|
+
buf->size += esc_prefix_len;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1102
1108
|
/* copy character to be escaped */
|
|
1103
1109
|
buf->ptr[buf->size] = *scan;
|
|
1104
1110
|
buf->size++;
|
|
1105
1111
|
scan++;
|
|
1112
|
+
|
|
1113
|
+
/* copy escape suffix sequence */
|
|
1114
|
+
if (esc_suffix) {
|
|
1115
|
+
memmove(buf->ptr + buf->size, esc_suffix, esc_suffix_len);
|
|
1116
|
+
buf->size += esc_suffix_len;
|
|
1117
|
+
}
|
|
1106
1118
|
}
|
|
1107
1119
|
}
|
|
1108
1120
|
|
|
@@ -268,21 +268,23 @@ int git_str_splice(
|
|
|
268
268
|
* @param str String buffer to append data to
|
|
269
269
|
* @param string String to escape and append
|
|
270
270
|
* @param esc_chars Characters to be escaped
|
|
271
|
-
* @param
|
|
271
|
+
* @param esc_prefix String to insert as prefix of each found character
|
|
272
|
+
* @param esc_suffix String to insert as suffix of each found character
|
|
272
273
|
* @return 0 on success, <0 on failure (probably allocation problem)
|
|
273
274
|
*/
|
|
274
275
|
extern int git_str_puts_escaped(
|
|
275
276
|
git_str *str,
|
|
276
277
|
const char *string,
|
|
277
278
|
const char *esc_chars,
|
|
278
|
-
const char *
|
|
279
|
+
const char *esc_prefix,
|
|
280
|
+
const char *esc_suffix);
|
|
279
281
|
|
|
280
282
|
/**
|
|
281
283
|
* Append string escaping characters that are regex special
|
|
282
284
|
*/
|
|
283
285
|
GIT_INLINE(int) git_str_puts_escape_regex(git_str *str, const char *string)
|
|
284
286
|
{
|
|
285
|
-
return git_str_puts_escaped(str, string, "^.[]$()|*+?{}\\", "\\");
|
|
287
|
+
return git_str_puts_escaped(str, string, "^.[]$()|*+?{}\\", "\\", NULL);
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
/**
|