shithub: tlsclient

Download patch

ref: fa83d0a67d9c796e60a13c5a7ce8e9d4d9e97871
parent: fb3b5e0ed5af8a73d549e336a649d5b6c2a115ad
author: Jacob Moody <moody@posixcafe.org>
date: Fri Jul 21 06:50:26 EDT 2023

respect quotes in mount helper options

--- a/mount.c
+++ b/mount.c
@@ -80,12 +80,22 @@
 {
 	char *s;
 	char *key, *val;
+	int inquote;
 
 	key = val = NULL;
+	inquote = 0;
 	for(s = opt; *s != '\0'; s++){
+		if(key == NULL)
+			key = s;
+		if(*s == '"'){
+			inquote = !inquote;
+			continue;
+		}
+		if(inquote)
+			continue;
 		switch(*s){
 		case '=':
-			if(key == NULL)
+			if(key == s)
 				errx(EINVAL, "option argument has no key, only a value");
 			*s = '\0';
 			if(s[1] == '\0')
@@ -93,7 +103,7 @@
 			val = s+1;
 			continue;
 		case ',':
-			if(key == NULL)
+			if(key == s)
 				errx(EINVAL, "extra comma");
 			*s = '\0';
 			appendopt(key, val);
@@ -100,9 +110,9 @@
 			key = val = NULL;
 			continue;
 		}
-		if(key == NULL)
-			key = s;
 	}
+	if(inquote)
+		errx(EINVAL, "unterminated double quote");
 	if(key != NULL)
 		appendopt(key, val);