Skip to content

Commit ef75ffd

Browse files
committed
rust: correctly validate symlinks with relative directory references
We never had these before. But I plan on adding them as part of shipping the terminfo database. This change is needed to avoid false validation errors if there are symlinks with e.g. `/../` in them.
1 parent 02c2a99 commit ef75ffd

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ flate2 = "1.0.28"
1414
futures = "0.3.30"
1515
goblin = "0.8.0"
1616
hex = "0.4.3"
17+
normalize-path = "0.2.1"
1718
object = "0.32.2"
1819
octocrab = { version = "0.19.0", features = ["rustls"] }
1920
once_cell = "1.19.0"
2021
rayon = "1.8.1"
21-
reqwest = {version = "0.11.24", features = ["rustls"] }
22+
reqwest = { version = "0.11.24", features = ["rustls"] }
2223
scroll = "0.12.0"
2324
semver = "1.0.22"
2425
serde_json = "1.0.114"

src/validation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use {
66
crate::{json::*, macho::*},
77
anyhow::{anyhow, Context, Result},
88
clap::ArgMatches,
9+
normalize_path::NormalizePath,
910
object::{
1011
elf::{
1112
FileHeader32, FileHeader64, ET_DYN, ET_EXEC, STB_GLOBAL, STB_WEAK, STV_DEFAULT,
@@ -1675,7 +1676,9 @@ fn validate_distribution(
16751676
seen_paths.insert(path.clone());
16761677

16771678
if let Some(link_name) = entry.link_name()? {
1678-
seen_symlink_targets.insert(path.parent().unwrap().join(link_name));
1679+
let target = path.parent().unwrap().join(link_name).normalize();
1680+
1681+
seen_symlink_targets.insert(target);
16791682
}
16801683

16811684
// If this path starts with a path referenced in wanted_python_paths,

0 commit comments

Comments
 (0)