Skip to content

Commit 42f643a

Browse files
committed
feat(patch_bin): no patching if no libc
Using suggestion from `woutvanderploeg` to not patch if there is no libc present. Mentioned io12#309
1 parent 2a6fcb6 commit 42f643a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/patch_bin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ fn bin_patched_path_from_bin(bin: &Path) -> Result<PathBuf> {
124124
}
125125

126126
/// Add "_patched" to the end of the binary file name if the binary got patched.
127+
/// Skip if there is no libc or if the user disabled patching.
127128
pub fn bin_patched_path(opts: &Opts) -> Option<PathBuf> {
128-
match opts.no_patch_bin {
129+
match opts.no_patch_bin || opts.libc.is_none() {
129130
true => None,
130131
false => opts
131132
.bin

src/pwninit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ pub fn run(opts: Opts) -> Result {
4949

5050
set_ld_exec(&opts).context(SetLdExecSnafu)?;
5151

52-
if !opts.no_patch_bin {
52+
// Skip if there is no libc.
53+
if !opts.no_patch_bin && opts.libc.is_some() {
5354
patch_bin::patch_bin(&opts).context(PatchBinSnafu)?;
5455
}
5556

0 commit comments

Comments
 (0)