Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix memory corruption if www was passed directly in manifest
Baptiste Daroussin committed 13 years ago
commit 7649153c65619c75875523bf4134073fc118f229
parent 1da7bc9
2 files changed +13 -7
modified libpkg/pkg_create.c
@@ -216,7 +216,7 @@ pkg_create_staged(const char *outdir, pkg_formats format, const char *rootdir,
	regex_t		 preg;
	regmatch_t	 pmatch[2];
	size_t		 size;
-
	char		*www;
+
	char		*www = NULL;

	/* Load the manifest from the metadata directory */
	if (snprintf(path, sizeof(path), "%s/+MANIFEST", md_dir) == -1)
@@ -283,6 +283,11 @@ pkg_create_staged(const char *outdir, pkg_formats format, const char *rootdir,
	}

	/* if www is not given then try to determine it from description */
+
	if (www != NULL) {
+
		pkg_set(pkg, PKG_WWW, www);
+
		free(www);
+
	}
+

	pkg_get(pkg, PKG_WWW, &www);
	if (www == NULL) {
		pkg_get(pkg, PKG_DESC, &buf);
@@ -302,9 +307,6 @@ pkg_create_staged(const char *outdir, pkg_formats format, const char *rootdir,
			pkg_set(pkg, PKG_WWW, "UNKNOWN");
		}
		regfree(&preg);
-
	} else {
-
		pkg_set(pkg, PKG_WWW, www);
-
		free(www);
	}

	/* Create the archive */
modified pkg/register.c
@@ -178,6 +178,13 @@ exec_register(int argc, char **argv)
			pkg_addscript_file(pkg, fpath);
	}

+
	if (www != NULL) {
+
		pkg_set(pkg, PKG_WWW, www);
+
		free(www);
+
	}
+

+
	pkg_get(pkg, PKG_WWW, &www);
+

	/* if www is not given then try to determine it from description */
	if (www == NULL) {
		pkg_get(pkg, PKG_DESC, &desc);
@@ -191,9 +198,6 @@ exec_register(int argc, char **argv)
			pkg_set(pkg, PKG_WWW, "UNKNOWN");
		}
		regfree(&preg);
-
	} else {
-
		pkg_set(pkg, PKG_WWW, www);
-
		free(www);
	}

	ret += ports_parse_plist(pkg, plist, input_path);