Fix incorrect GLIBC version parsing

Fixes #230370
This commit is contained in:
aslezar
2024-12-13 22:22:13 +05:30
parent e7b43262d2
commit e044a71719

View File

@@ -15,7 +15,7 @@ use super::errors::CodeError;
lazy_static! {
static ref LDCONFIG_STDC_RE: Regex = Regex::new(r"libstdc\+\+.* => (.+)").unwrap();
static ref LDD_VERSION_RE: BinRegex = BinRegex::new(r"^ldd.*(.+)\.(.+)\s").unwrap();
static ref LDD_VERSION_RE: BinRegex = BinRegex::new(r"^ldd.*\s(\d+)\.(\d+)(?:\.(\d+))?\s").unwrap();
static ref GENERIC_VERSION_RE: Regex = Regex::new(r"^([0-9]+)\.([0-9]+)$").unwrap();
static ref LIBSTD_CXX_VERSION_RE: BinRegex =
BinRegex::new(r"GLIBCXX_([0-9]+)\.([0-9]+)(?:\.([0-9]+))?").unwrap();
@@ -401,5 +401,18 @@ mod tests {
extract_ldd_version(&actual),
Some(SimpleSemver::new(2, 31, 0)),
);
let actual2 = "ldd (GNU libc) 2.40.9000
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper."
.to_owned()
.into_bytes();
assert_eq!(
extract_ldd_version(&actual2),
Some(SimpleSemver::new(2, 40, 0)),
);
}
}