Skip to content

Commit

Permalink
Align handling of invalid files between analyse_macho and analyse_elf
Browse files Browse the repository at this point in the history
  • Loading branch information
Keve authored and bapt committed Dec 6, 2024
1 parent 306fc12 commit e518c4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions libpkg/binfmt_macho.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ read_fully(const int fd, const size_t len, void *dest)
ssize_t x;
while (n > 0) {
if ((x = read(fd, p, n)) < 0) {
if ( EAGAIN == errno) {
continue;
}
return x;
}
if ( 0 == x) {
return -1;
}
n -= x;
p += x;
}
Expand Down
8 changes: 5 additions & 3 deletions libpkg/pkg_abi_macho.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,14 @@ pkg_analyse_macho(const bool developer_mode, struct pkg *pkg, const char *fpath)

int fd = open(fpath, O_RDONLY);
if (-1 == fd) {
pkg_emit_errno("open", fpath);
ret = EPKG_FATAL;
// pkg_emit_errno("open_pkg_analyse_macho", fpath);
// ret = EPKG_FATAL;
// Be consistent with analyse_elf and return no error if fpath cannot be opened
return ret;
} else {
ret = analyse_macho(fd, pkg, baselibs);
if (-1 == close(fd)) {
pkg_emit_errno("open", fpath);
pkg_emit_errno("close_pkg_analyse_macho", fpath);
ret = EPKG_FATAL;
}
}
Expand Down

0 comments on commit e518c4c

Please sign in to comment.