Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Avoid use-after-free
Matthew Seaman committed 13 years ago
commit 61be4bffc24ff472fa8c7c0136d026218cbe3873
parent c4f611c
3 files changed +11 -5
modified libpkg/pkg.h
@@ -447,7 +447,7 @@ int pkg_analyse_files(struct pkgdb *, struct pkg *);
 * Suggest if a package could be marked architecture independent or
 * not.
 */
-
int pkg_suggest_arch(struct pkg *, const char *);
+
int pkg_suggest_arch(struct pkg *, const char *, bool);

/**
 * Generic setter for simple attributes.
modified libpkg/pkg_elf.c
@@ -458,8 +458,13 @@ pkg_get_myarch_indep(char *dest, size_t sz)
}

int
-
pkg_suggest_arch(struct pkg *pkg, const char *arch)
+
pkg_suggest_arch(struct pkg *pkg, const char *arch, bool isdefault)
{
+
	bool iswildcard;
+

+
	/* Is a wildcard arch already in use? */
+

+

	if (pkg->flags & (PKG_CONTAINS_ELF_OBJECTS|PKG_CONTAINS_STATIC_LIBS)) {
		/* Definitely has to be arch specific */
		pkg_emit_error("Package installs architecture specific files");
modified pkg/register.c
@@ -205,15 +205,16 @@ exec_register(int argc, char **argv)
		 * but the real abi of the package.
		 */
		pkg_get_myarch(myarch, BUFSIZ);
+
		if (developer)
+
			pkg_suggest_arch(pkg, myarch, true);
		pkg_set(pkg, PKG_ARCH, myarch);
	} else {
+
		if (developer)
+
			pkg_suggest_arch(pkg, arch, false);
		pkg_set(pkg, PKG_ARCH, arch);
		free(arch);
	}

-
	if (developer)
-
		pkg_suggest_arch(pkg, arch);
-

	if (input_path != NULL) {
		pkg_copy_tree(pkg, input_path, "/");
		free(input_path);