Skip to content

Commit 273dc30

Browse files
committed
rust: always return list of allowed dynamic libraries for a triple
This is called outside the context of Mach-O, so we need to always succeed.
1 parent 0663025 commit 273dc30

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ lazy_static! {
249249
};
250250
}
251251

252-
fn allowed_dylibs_for_triple(triple: &str) -> Result<&Vec<MachOAllowedDylib>> {
252+
fn allowed_dylibs_for_triple(triple: &str) -> Vec<MachOAllowedDylib> {
253253
match triple {
254-
"aarch64-apple-darwin" => Ok(&*DARWIN_ALLOWED_DYLIBS),
255-
"x86_64-apple-darwin" => Ok(&*DARWIN_ALLOWED_DYLIBS),
256-
"aarch64-apple-ios" => Ok(&*IOS_ALLOWED_DYLIBS),
257-
"x86_64-apple-ios" => Ok(&*IOS_ALLOWED_DYLIBS),
258-
_ => Err(anyhow!("unhandled target triple: {}", triple))
254+
"aarch64-apple-darwin" => DARWIN_ALLOWED_DYLIBS.clone(),
255+
"x86_64-apple-darwin" => DARWIN_ALLOWED_DYLIBS.clone(),
256+
"aarch64-apple-ios" => IOS_ALLOWED_DYLIBS.clone(),
257+
"x86_64-apple-ios" => IOS_ALLOWED_DYLIBS.clone(),
258+
_ => vec![]
259259
}
260260
}
261261

@@ -330,7 +330,7 @@ fn validate_macho(
330330
| CommandVariant::LazyLoadDylib(command) => {
331331
let lib = bytes.pread::<&str>(load_command.offset + command.dylib.name as usize)?;
332332

333-
let allowed = allowed_dylibs_for_triple(target_triple)?;
333+
let allowed = allowed_dylibs_for_triple(target_triple);
334334

335335
if let Some(entry) = allowed.iter().find(|l| l.name == lib) {
336336
let load_version =
@@ -429,10 +429,10 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
429429
}
430430
}
431431

432-
let wanted_dylibs = BTreeSet::from_iter(allowed_dylibs_for_triple(triple)?.iter().filter(|d| d.required).map(|d| d.name.clone()));
432+
let wanted_dylibs = BTreeSet::from_iter(allowed_dylibs_for_triple(triple).iter().filter(|d| d.required).map(|d| d.name.clone()));
433433

434434
for lib in wanted_dylibs.difference(&seen_dylibs) {
435-
errors.push(format!("required dylib dependency {} not seen", lib));
435+
errors.push(format!("required library dependency {} not seen", lib));
436436
}
437437

438438
Ok(errors)

0 commit comments

Comments
 (0)