Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Jul 21, 2024
1 parent 7c805b1 commit ea336da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
tests/out

# Node artifact files
node_modules/
Expand Down
8 changes: 4 additions & 4 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//! # fn main() -> Result<(), libsui::Error> {
//! let data = b"Hello, world!";
//! let exe = std::fs::read("tests/exec_mach64")?;
//! let mut out = File::create("out")?;
//! let mut out = File::create("tests/out")?;
//!
//! Macho::from(exe)?
//! .write_section("__SECTION", data.to_vec())?
Expand Down Expand Up @@ -351,16 +351,16 @@ impl Macho {
flags: 0,
};

// Copy section name
let sectname = name.as_bytes();
let mut sectname = [0; 16];
sectname[..name.len()].copy_from_slice(name.as_bytes());

self.sec = Section64 {
addr: self.seg.vmaddr,
size: sectdata.len() as u64,
offset: self.linkedit_cmd.fileoff as u32,
align: if sectdata.len() < 16 { 0 } else { 4 },
segname: SEGNAME,
sectname: sectname.try_into().map_err(|_| Error::InternalError)?,
sectname,
..self.sec
};

Expand Down
Binary file added tests/exec_mach64
Binary file not shown.

0 comments on commit ea336da

Please sign in to comment.