Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
f200c147
Commit
f200c147
authored
Jun 17, 2022
by
longpanda
Browse files
fix build error
parent
c0901977
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
12 deletions
+58
-12
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+58
-12
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
f200c147
...
@@ -3367,30 +3367,76 @@ end:
...
@@ -3367,30 +3367,76 @@ end:
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
}
static
int
ventoy_is_builtin_var
(
const
char
*
var
)
{
int
i
;
const
char
*
c
;
const
char
*
builtin_vars_full
[]
=
{
"VT_DISK_1ST_NONVTOY"
,
"VT_DISK_1ST_NONUSB"
,
NULL
};
for
(
i
=
0
;
builtin_vars_full
[
i
];
i
++
)
{
if
(
grub_strcmp
(
builtin_vars_full
[
i
],
var
)
==
0
)
{
return
1
;
}
}
if
(
grub_strncmp
(
var
,
"VT_DISK_CLOSEST_"
,
16
)
==
0
)
{
c
=
var
+
16
;
while
(
*
c
)
{
if
(
*
c
<
'0'
||
*
c
>
'9'
)
{
break
;
}
c
++
;
}
if
(
*
c
==
0
&&
c
!=
(
var
+
16
))
{
return
1
;
}
}
return
0
;
}
static
int
ventoy_var_expand
(
int
*
flag
,
const
char
*
var
,
char
*
expand
,
int
len
)
static
int
ventoy_var_expand
(
int
*
flag
,
const
char
*
var
,
char
*
expand
,
int
len
)
{
{
int
i
=
0
;
int
i
=
0
;
int
n
=
0
;
int
n
=
0
;
char
c
;
char
c
;
const
char
*
c
=
var
;
const
char
*
ch
=
var
;
grub_uint8_t
bytes
[
32
];
expand
[
0
]
=
0
;
expand
[
0
]
=
0
;
while
(
*
c
)
while
(
*
c
h
)
{
{
if
(
*
c
==
'_'
||
(
*
c
>=
'0'
&&
*
c
<=
'9'
)
||
(
*
c
>=
'A'
&&
*
c
<=
'Z'
))
if
(
*
c
h
==
'_'
||
(
*
c
h
>=
'0'
&&
*
c
h
<=
'9'
)
||
(
*
c
h
>=
'A'
&&
*
c
h
<=
'Z'
))
{
{
c
++
;
ch
++
;
n
++
;
}
}
else
else
{
{
debug
(
"Invalid variable letter <%c>
\n
"
,
*
c
);
debug
(
"Invalid variable letter <%c>
\n
"
,
*
c
h
);
goto
end
;
goto
end
;
}
}
}
}
if
(
grub_strncmp
(
var
,
"VT_RAND_9"
,
9
)
==
0
)
if
(
n
>
32
)
{
debug
(
"Invalid variable length:%d <%s>
\n
"
,
n
,
var
);
goto
end
;
}
if
(
ventoy_is_builtin_var
(
var
))
{
{
}
}
...
@@ -3447,7 +3493,7 @@ static int ventoy_var_expand(int *flag, const char *var, char *expand, int len)
...
@@ -3447,7 +3493,7 @@ static int ventoy_var_expand(int *flag, const char *var, char *expand, int len)
end:
end:
if
(
expand
[
0
]
==
0
)
if
(
expand
[
0
]
==
0
)
{
{
grub_snprintf
(
expand
,
len
,
"$
<
%s
>
$"
,
var
);
grub_snprintf
(
expand
,
len
,
"$
$
%s
$
$"
,
var
);
}
}
return
0
;
return
0
;
...
@@ -3480,14 +3526,14 @@ static int ventoy_auto_install_var_expand(install_template *node)
...
@@ -3480,14 +3526,14 @@ static int ventoy_auto_install_var_expand(install_template *node)
return
0
;
return
0
;
}
}
start
=
grub_strstr
(
node
->
filebuf
,
"$
<
"
);
start
=
grub_strstr
(
node
->
filebuf
,
"$
$
"
);
if
(
!
start
)
if
(
!
start
)
{
{
debug
(
"no need to expand variable, no start.
\n
"
);
debug
(
"no need to expand variable, no start.
\n
"
);
return
0
;
return
0
;
}
}
end
=
grub_strstr
(
start
+
2
,
"
>
$"
);
end
=
grub_strstr
(
start
+
2
,
"
$
$"
);
if
(
!
end
)
if
(
!
end
)
{
{
debug
(
"no need to expand variable, no end.
\n
"
);
debug
(
"no need to expand variable, no end.
\n
"
);
...
@@ -3506,10 +3552,10 @@ static int ventoy_auto_install_var_expand(install_template *node)
...
@@ -3506,10 +3552,10 @@ static int ventoy_auto_install_var_expand(install_template *node)
{
{
nextline
=
ventoy_get_line
(
curline
);
nextline
=
ventoy_get_line
(
curline
);
start
=
grub_strstr
(
curline
,
"$
<
"
);
start
=
grub_strstr
(
curline
,
"$
$
"
);
if
(
start
)
if
(
start
)
{
{
end
=
grub_strstr
(
start
+
2
,
"
>
$"
);
end
=
grub_strstr
(
start
+
2
,
"
$
$"
);
}
}
if
(
start
&&
end
)
if
(
start
&&
end
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment