Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Some perl elf doesn't have a note section
Baptiste Daroussin committed 14 years ago
commit 6d39d412b2baf2db8652a3e101b0e156431aadf9
parent c1e3734b93c953e91dd26cf526dd42550d5db352
1 file changed +14 -1
modified libpkg/pkg_elf.c
@@ -113,6 +113,7 @@ static int
analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
{
	Elf *e;
+
	GElf_Ehdr elfhdr;
	Elf_Scn *scn = NULL;
	Elf_Scn *note = NULL;
	Elf_Scn *dynamic = NULL;
@@ -154,6 +155,12 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
		return (EPKG_END); /* Not an elf file: no results */
	}

+
	if (gelf_getehdr(e, &elfhdr) == NULL) {
+
		ret = EPKG_FATAL;
+
		pkg_emit_error("getehdr() failed: %s.", elf_errmsg(-1));
+
		goto cleanup;
+
	}
+

	while (( scn = elf_nextscn(e, scn)) != NULL) {
		if (gelf_getshdr(scn, &shdr) != &shdr) {
			ret = EPKG_FATAL;
@@ -175,11 +182,17 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
	 * note == NULL means no freebsd
	 * dynamic == NULL means not a dynamic linked elf
	 */
-
	if (dynamic == NULL || note == NULL) {
+
	if (dynamic == NULL) {
		ret = EPKG_END;
		goto cleanup; /* not a dynamically linked elf: no results */
	}

+
	/* some freebsd binaries doesn't have notes like some perl modules */
+
	if (note == NULL && elfhdr.e_ident[EI_OSABI] != ELFOSABI_FREEBSD) {
+
		ret = EPKG_END;
+
		goto cleanup;
+
	}
+

	data = elf_getdata(note, NULL);
	osname = (const char *) data->d_buf + sizeof(Elf_Note);
	if (strncasecmp(osname, "freebsd", sizeof("freebsd")) != 0) {