Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Align handling of invalid files between analyse_macho and analyse_elf
Keve committed 1 year ago
commit e518c4ccf55bf93c2a2bc578e60a2b856a7c3978
parent 306fc12
2 files changed +11 -3
modified libpkg/binfmt_macho.c
@@ -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;
	}
modified libpkg/pkg_abi_macho.c
@@ -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;
		}
	}