aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-06-19 23:02:15 -0400
committerMike Frysinger <vapier@gentoo.org>2016-06-19 23:02:15 -0400
commit0feba3c91ca51bc68f5ba8688c91f772d81cb0ce (patch)
tree0e32fa9adbc0c2cd6b54e10750a8f50554224f8a
parentar: make sure name is always NUL terminated (diff)
downloadpax-utils-0feba3c91ca51bc68f5ba8688c91f772d81cb0ce.tar.gz
pax-utils-0feba3c91ca51bc68f5ba8688c91f772d81cb0ce.tar.bz2
pax-utils-0feba3c91ca51bc68f5ba8688c91f772d81cb0ce.zip
paxmacho: simplify readmacho a bit
The readmacho_fd helper will already use fstat on the fd if we pass in a length of 0, so let that work rather than do stat/open since there is a minor race there.
-rw-r--r--paxmacho.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/paxmacho.c b/paxmacho.c
index 090fc18..142af6e 100644
--- a/paxmacho.c
+++ b/paxmacho.c
@@ -189,16 +189,12 @@ inline static uint32_t read_mach_header(fatobj *fobj, void *addr)
* arch. */
fatobj *readmacho(const char *filename)
{
- struct stat st;
int fd;
- if (stat(filename, &st) == -1)
- return NULL;
-
if ((fd = open(filename, O_RDONLY)) == -1)
return NULL;
- return readmacho_fd(filename, fd, st.st_size);
+ return readmacho_fd(filename, fd, 0);
}
fatobj *readmacho_fd(const char *filename, int fd, size_t len)