Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix attempt to parse trailing junk on a line as a valid option, by checking for characters we know will be in any valid options string.
Matthew Seaman committed 13 years ago
commit ef541eb020d66e354fdb51d57282c6b692929ddf
parent 83c618f
1 file changed +5 -4
modified libpkg/pkg_ports.c
@@ -392,7 +392,7 @@ setgroup(struct plist *p, char *line, struct file_attr *a)
static int
comment_key(struct plist *p, char *line, struct file_attr *a)
{
-
	char *name, *version, *line_options, *option;
+
	char *name, *version, *line_options, *line_options2, *option;

	if (strncmp(line, "DEPORIGIN:", 10) == 0) {
		line += 10;
@@ -409,13 +409,14 @@ comment_key(struct plist *p, char *line, struct file_attr *a)
		line += 8;
		/* OPTIONS:+OPTION -OPTION */
		if (line[0] != '\0') {
-
			line_options = strdup(line);
+
			line_options2 = line_options = strdup(line);
			while ((option = strsep(&line_options, " ")) != NULL) {
-
				if (option[0] != '\0')
+
				if ((option[0] == '+' || option[0] == '-') &&
+
				    option[1] != '\0' && isupper(option[1]))
					pkg_addoption(p->pkg, option + 1,
					    option[0] == '+' ? "on" : "off");
			}
-
			free(line_options);
+
			free(line_options2);
		}
	}