Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131445767
D6000.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D6000.diff
View Options
Index: head/sys/boot/common/interp_parse.c
===================================================================
--- head/sys/boot/common/interp_parse.c
+++ head/sys/boot/common/interp_parse.c
@@ -72,7 +72,13 @@
static int
isquote(int ch)
{
- return (ch == '\'' || ch == '"');
+ return (ch == '\'');
+}
+
+static int
+isdquote(int ch)
+{
+ return (ch == '"');
}
int
@@ -81,11 +87,11 @@
int ac;
char *val, *p, *q, *copy = NULL;
size_t i = 0;
- char token, tmp, quote, *buf;
+ char token, tmp, quote, dquote, *buf;
enum { STR, VAR, WHITE } state;
ac = *argc = 0;
- quote = 0;
+ dquote = quote = 0;
if (!str || (p = copy = backslash(str)) == NULL)
return 1;
@@ -105,9 +111,19 @@
buf[i++] = *p++;
} else if (isquote(*p)) {
quote = quote ? 0 : *p;
- ++p;
- }
- else if (isspace(*p) && !quote) {
+ if (dquote) { /* keep quote */
+ PARSE_FAIL(i == (PARSE_BUFSIZE - 1));
+ buf[i++] = *p++;
+ } else
+ ++p;
+ } else if (isdquote(*p)) {
+ dquote = dquote ? 0 : *p;
+ if (quote) { /* keep dquote */
+ PARSE_FAIL(i == (PARSE_BUFSIZE - 1));
+ buf[i++] = *p++;
+ } else
+ ++p;
+ } else if (isspace(*p) && !quote && !dquote) {
state = WHITE;
if (i) {
buf[i] = '\0';
@@ -115,7 +131,7 @@
i = 0;
}
++p;
- } else if (*p == '$') {
+ } else if (*p == '$' && !quote) {
token = isdelim(*(p + 1));
if (token)
p += 2;
@@ -157,6 +173,8 @@
break;
}
}
+ /* missing terminating ' or " */
+ PARSE_FAIL(quote || dquote);
/* If at end of token, add it */
if (i && state == STR) {
buf[i] = '\0';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 9, 3:42 AM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23467391
Default Alt Text
D6000.diff (1 KB)
Attached To
Mode
D6000: parse() in boot loader interp_parse.c is too naive about quotes
Attached
Detach File
Event Timeline
Log In to Comment