Skip to content

Commit e86aaf5

Browse files
davidknaehuss
andcommitted
update libgit2 to newer snapshot
CVE 2022-24765 Co-Authored-By: Eric Huss <[email protected]>
1 parent 61f8afd commit e86aaf5

File tree

9 files changed

+49
-15
lines changed

9 files changed

+49
-15
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "git2"
3-
version = "0.14.4"
3+
version = "0.15.0"
44
authors = ["Josh Triplett <[email protected]>", "Alex Crichton <[email protected]>"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -20,7 +20,7 @@ url = "2.0"
2020
bitflags = "1.1.0"
2121
libc = "0.2"
2222
log = "0.4.8"
23-
libgit2-sys = { path = "libgit2-sys", version = "0.13.4" }
23+
libgit2-sys = { path = "libgit2-sys", version = "0.14.0" }
2424

2525
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies]
2626
openssl-sys = { version = "0.9.0", optional = true }

git2-curl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ edition = "2018"
1616
curl = "0.4.33"
1717
url = "2.0"
1818
log = "0.4"
19-
git2 = { path = "..", version = "0.14", default-features = false }
19+
git2 = { path = "..", version = "0.15", default-features = false }
2020

2121
[dev-dependencies]
2222
civet = "0.11"

libgit2-sys/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libgit2-sys"
3-
version = "0.13.4+1.4.2"
3+
version = "0.14.0+1.4.4"
44
authors = ["Josh Triplett <[email protected]>", "Alex Crichton <[email protected]>"]
55
links = "git2"
66
build = "build.rs"

libgit2-sys/build.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ fn main() {
1414
let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
1515
if try_to_use_system_libgit2 {
1616
let mut cfg = pkg_config::Config::new();
17-
if let Ok(lib) = cfg
18-
.range_version("1.4.0".."1.5.0")
19-
.print_system_libs(false)
20-
.probe("libgit2")
21-
{
17+
if let Ok(lib) = cfg.range_version("1.4.4".."1.5.0").probe("libgit2") {
2218
for include in &lib.include_paths {
2319
println!("cargo:root={}", include.display());
2420
}
@@ -162,9 +158,26 @@ fn main() {
162158
cfg.define("SHA1DC_NO_STANDARD_INCLUDES", "1");
163159
cfg.define("SHA1DC_CUSTOM_INCLUDE_SHA1_C", "\"common.h\"");
164160
cfg.define("SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C", "\"common.h\"");
165-
cfg.file("libgit2/src/util/hash/sha1/collisiondetect.c");
166-
cfg.file("libgit2/src/util/hash/sha1/sha1dc/sha1.c");
167-
cfg.file("libgit2/src/util/hash/sha1/sha1dc/ubc_check.c");
161+
cfg.file("libgit2/src/util/hash/collisiondetect.c");
162+
cfg.file("libgit2/src/util/hash/sha1dc/sha1.c");
163+
cfg.file("libgit2/src/util/hash/sha1dc/ubc_check.c");
164+
165+
if https {
166+
if windows {
167+
features.push_str("#define GIT_SHA256_WIN32 1\n");
168+
cfg.file("libgit2/src/util/hash/win32.c");
169+
} else if target.contains("apple") {
170+
features.push_str("#define GIT_SHA256_COMMON_CRYPTO 1\n");
171+
cfg.file("libgit2/src/util/hash/common_crypto.c");
172+
} else {
173+
features.push_str("#define GIT_SHA256_OPENSSL 1\n");
174+
cfg.file("libgit2/src/util/hash/openssl.c");
175+
}
176+
} else {
177+
features.push_str("#define GIT_SHA256_BUILTIN 1\n");
178+
cfg.file("libgit2/src/util/hash/builtin.c");
179+
cfg.file("libgit2/src/util/hash/rfc6234/sha224-256.c");
180+
}
168181

169182
if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
170183
cfg.include(path);

libgit2-sys/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.13")]
1+
#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.14")]
22
#![allow(non_camel_case_types, unused_extern_crates)]
33

44
// This is required to link libz when libssh2-sys is not included.
@@ -195,6 +195,7 @@ git_enum! {
195195
GIT_EMISMATCH = -33,
196196
GIT_EINDEXDIRTY = -34,
197197
GIT_EAPPLYFAIL = -35,
198+
GIT_EOWNER = -36,
198199
}
199200
}
200201

@@ -1894,6 +1895,8 @@ git_enum! {
18941895
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
18951896
GIT_OPT_GET_EXTENSIONS,
18961897
GIT_OPT_SET_EXTENSIONS,
1898+
GIT_OPT_GET_OWNER_VALIDATION,
1899+
GIT_OPT_SET_OWNER_VALIDATION,
18971900
}
18981901
}
18991902

libgit2-sys/libgit2

Submodule libgit2 updated 160 files

src/error.rs

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl Error {
127127
raw::GIT_EMISMATCH => super::ErrorCode::HashsumMismatch,
128128
raw::GIT_EINDEXDIRTY => super::ErrorCode::IndexDirty,
129129
raw::GIT_EAPPLYFAIL => super::ErrorCode::ApplyFail,
130+
raw::GIT_EOWNER => super::ErrorCode::Owner,
130131
_ => super::ErrorCode::GenericError,
131132
}
132133
}
@@ -163,6 +164,7 @@ impl Error {
163164
ErrorCode::HashsumMismatch => raw::GIT_EMISMATCH,
164165
ErrorCode::IndexDirty => raw::GIT_EINDEXDIRTY,
165166
ErrorCode::ApplyFail => raw::GIT_EAPPLYFAIL,
167+
ErrorCode::Owner => raw::GIT_EOWNER,
166168
};
167169
}
168170

@@ -293,6 +295,7 @@ impl Error {
293295
GIT_EMISMATCH,
294296
GIT_EINDEXDIRTY,
295297
GIT_EAPPLYFAIL,
298+
GIT_EOWNER,
296299
)
297300
}
298301

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
//! source `Repository`, to ensure that they do not outlive the repository
6666
//! itself.
6767
68-
#![doc(html_root_url = "https://docs.rs/git2/0.14")]
68+
#![doc(html_root_url = "https://docs.rs/git2/0.15")]
6969
#![allow(trivial_numeric_casts, trivial_casts)]
7070
#![deny(missing_docs)]
7171
#![warn(rust_2018_idioms)]
@@ -215,6 +215,8 @@ pub enum ErrorCode {
215215
IndexDirty,
216216
/// Patch application failed
217217
ApplyFail,
218+
/// The object is not owned by the current user
219+
Owner,
218220
}
219221

220222
/// An enumeration of possible categories of things that can have

src/opts.rs

+13
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ where
178178
Ok(())
179179
}
180180

181+
/// Set wheter or not to verify ownership before performing a repository.
182+
/// Enabled by default, but disabling this can lead to code execution vulnerabilities.
183+
pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
184+
let error = raw::git_libgit2_opts(
185+
raw::GIT_OPT_SET_OWNER_VALIDATION as libc::c_int,
186+
enabled as libc::c_int,
187+
);
188+
// This function cannot actually fail, but the function has an error return
189+
// for other options that can.
190+
debug_assert!(error >= 0);
191+
Ok(())
192+
}
193+
181194
#[cfg(test)]
182195
mod test {
183196
use super::*;

0 commit comments

Comments
 (0)