Fix remote callback string output out of bounds mem read

Also changes the diff format to the Git default, from diff3
This commit is contained in:
Twarit Waikar
2021-10-08 00:08:24 +05:30
parent ac32fcc708
commit 5aa5343d53
2 changed files with 11 additions and 8 deletions

View File

@@ -556,7 +556,7 @@ void GitAPI::_pull(String remote, String username, String password) {
merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_NORMAL; merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_NORMAL;
merge_opts.file_flags = (GIT_MERGE_FILE_STYLE_DIFF3 | GIT_MERGE_FILE_DIFF_MINIMAL); merge_opts.file_flags = (GIT_MERGE_FILE_STYLE_DIFF3 | GIT_MERGE_FILE_DIFF_MINIMAL);
checkout_opts.checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS | GIT_CHECKOUT_CONFLICT_STYLE_DIFF3); checkout_opts.checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS | GIT_CHECKOUT_CONFLICT_STYLE_MERGE);
GIT2_CALL("Merge Failed", GIT2_CALL("Merge Failed",
git_merge, repo.get(), merge_heads, 1, &merge_opts, &checkout_opts); git_merge, repo.get(), merge_heads, 1, &merge_opts, &checkout_opts);
@@ -565,9 +565,9 @@ void GitAPI::_pull(String remote, String username, String password) {
git_repository_index, index, repo.get()); git_repository_index, index, repo.get());
if (git_index_has_conflicts(index.get())) { if (git_index_has_conflicts(index.get())) {
Godot::print("GitAPI: Index has conflicts, Solve conflicts and make a merge commit."); popup_error("GitAPI: Index has conflicts, Solve conflicts and make a merge commit.");
} else { } else {
Godot::print("GitAPI: Change are staged, make a merge commit."); popup_error("GitAPI: Change are staged, make a merge commit.");
} }
has_merge = true; has_merge = true;

View File

@@ -3,7 +3,12 @@
extern "C" int progress_cb(const char *str, int len, void *data) { extern "C" int progress_cb(const char *str, int len, void *data) {
(void)data; (void)data;
godot::Godot::print("remote: " + godot::String(str).strip_edges()); godot::String progress_str;
for (int i = 0; i < len; i++) {
progress_str += str[i];
}
godot::Godot::print("remote: " + progress_str.strip_edges());
return 0; return 0;
} }
@@ -13,13 +18,11 @@ extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b
char b_str[short_commit_length + 1]; char b_str[short_commit_length + 1];
(void)data; (void)data;
git_oid_tostr(b_str, short_commit_length - 1, b); git_oid_tostr(b_str, short_commit_length, b);
b_str[short_commit_length] = '\0';
if (git_oid_is_zero(a)) { if (git_oid_is_zero(a)) {
godot::Godot::print("* [new] " + godot::String(b_str) + " " + godot::String(refname)); godot::Godot::print("* [new] " + godot::String(b_str) + " " + godot::String(refname));
} else { } else {
git_oid_nfmt(a_str, short_commit_length - 1, a); git_oid_tostr(a_str, short_commit_length, a);
a_str[short_commit_length] = '\0';
godot::Godot::print("[updated] " + godot::String(a_str) + "..." + godot::String(b_str) + " " + godot::String(refname)); godot::Godot::print("[updated] " + godot::String(a_str) + "..." + godot::String(b_str) + " " + godot::String(refname));
} }