Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix a regression is plist parser
Baptiste Daroussin committed 13 years ago
commit 6704b848acbb249d125e584ef67a29d811f7767b
parent 1f19eb6
2 files changed +6 -6
modified libpkg/pkg_ports.c
@@ -58,7 +58,7 @@ struct keyword {
};

struct plist {
-
	char *last_file;
+
	char last_file[MAXPATHLEN];
	const char *stage;
	char prefix[MAXPATHLEN];
	struct sbuf *pre_install_buf;
@@ -983,7 +983,7 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *stage)
	assert(pkg != NULL);
	assert(plist != NULL);

-
	pplist.last_file = NULL;
+
	pplist.last_file[0] = '\0';
	pplist.prefix[0] = '\0';
	pplist.stage = stage;
	pplist.pre_install_buf = sbuf_new_auto();
@@ -1058,7 +1058,7 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *stage)
			}
		} else {
			buf = line;
-
			pplist.last_file = buf;
+
			strlcpy(pplist.last_file, buf, sizeof(pplist.last_file));

			/* remove spaces at the begining and at the end */
			while (isspace(buf[0]))
modified libpkg/utils.c
@@ -195,7 +195,7 @@ format_exec_cmd(char **dest, const char *in, const char *prefix,
			sbuf_cat(buf, prefix);
			break;
		case 'F':
-
			if (plist_file == NULL) {
+
			if (plist_file == NULL || plist_file[0] == '\0') {
				pkg_emit_error("No files defined %%F couldn't "
				    "be expanded, ignoring %s", in);
				sbuf_finish(buf);
@@ -205,7 +205,7 @@ format_exec_cmd(char **dest, const char *in, const char *prefix,
			sbuf_cat(buf, plist_file);
			break;
		case 'f':
-
			if (plist_file == NULL) {
+
			if (plist_file == NULL || plist_file[0] == '\0') {
				pkg_emit_error("No files defined %%f couldn't "
				    "be expanded, ignoring %s", in);
				sbuf_finish(buf);
@@ -223,7 +223,7 @@ format_exec_cmd(char **dest, const char *in, const char *prefix,
			sbuf_cat(buf, cp);
			break;
		case 'B':
-
			if (plist_file == NULL) {
+
			if (plist_file == NULL || plist_file[0] == '\0') {
				pkg_emit_error("No files defined %%B couldn't "
				    "be expanded, ignoring %s", in);
				sbuf_finish(buf);