Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
65e62b50
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65e62b50
编写于
5月 03, 2012
作者:
L
Linus Torvalds
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'efi-vars' from Matthew Garrett
* efi-vars: efivars: Improve variable validation
上级
6b4c555a
54b3a4d3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
16 deletion
+30
-16
drivers/firmware/efivars.c
drivers/firmware/efivars.c
+30
-16
未找到文件。
drivers/firmware/efivars.c
浏览文件 @
65e62b50
...
...
@@ -192,18 +192,21 @@ utf16_strncmp(const efi_char16_t *a, const efi_char16_t *b, size_t len)
}
static
bool
validate_device_path
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
int
len
)
validate_device_path
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
unsigned
long
len
)
{
struct
efi_generic_dev_path
*
node
;
int
offset
=
0
;
node
=
(
struct
efi_generic_dev_path
*
)
buffer
;
while
(
offset
<
len
)
{
offset
+=
node
->
length
;
if
(
len
<
sizeof
(
*
node
))
return
false
;
if
(
offset
>
len
)
return
false
;
while
(
offset
<=
len
-
sizeof
(
*
node
)
&&
node
->
length
>=
sizeof
(
*
node
)
&&
node
->
length
<=
len
-
offset
)
{
offset
+=
node
->
length
;
if
((
node
->
type
==
EFI_DEV_END_PATH
||
node
->
type
==
EFI_DEV_END_PATH2
)
&&
...
...
@@ -222,7 +225,8 @@ validate_device_path(struct efi_variable *var, int match, u8 *buffer, int len)
}
static
bool
validate_boot_order
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
int
len
)
validate_boot_order
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
unsigned
long
len
)
{
/* An array of 16-bit integers */
if
((
len
%
2
)
!=
0
)
...
...
@@ -232,19 +236,27 @@ validate_boot_order(struct efi_variable *var, int match, u8 *buffer, int len)
}
static
bool
validate_load_option
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
int
len
)
validate_load_option
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
unsigned
long
len
)
{
u16
filepathlength
;
int
i
,
desclength
=
0
;
int
i
,
desclength
=
0
,
namelen
;
namelen
=
utf16_strnlen
(
var
->
VariableName
,
sizeof
(
var
->
VariableName
));
/* Either "Boot" or "Driver" followed by four digits of hex */
for
(
i
=
match
;
i
<
match
+
4
;
i
++
)
{
if
(
hex_to_bin
(
var
->
VariableName
[
i
]
&
0xff
)
<
0
)
if
(
var
->
VariableName
[
i
]
>
127
||
hex_to_bin
(
var
->
VariableName
[
i
]
&
0xff
)
<
0
)
return
true
;
}
/* A valid entry must be at least 6 bytes */
if
(
len
<
6
)
/* Reject it if there's 4 digits of hex and then further content */
if
(
namelen
>
match
+
4
)
return
false
;
/* A valid entry must be at least 8 bytes */
if
(
len
<
8
)
return
false
;
filepathlength
=
buffer
[
4
]
|
buffer
[
5
]
<<
8
;
...
...
@@ -253,7 +265,7 @@ validate_load_option(struct efi_variable *var, int match, u8 *buffer, int len)
* There's no stored length for the description, so it has to be
* found by hand
*/
desclength
=
utf16_strsize
((
efi_char16_t
*
)(
buffer
+
6
),
len
)
+
2
;
desclength
=
utf16_strsize
((
efi_char16_t
*
)(
buffer
+
6
),
len
-
6
)
+
2
;
/* Each boot entry must have a descriptor */
if
(
!
desclength
)
...
...
@@ -275,7 +287,8 @@ validate_load_option(struct efi_variable *var, int match, u8 *buffer, int len)
}
static
bool
validate_uint16
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
int
len
)
validate_uint16
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
unsigned
long
len
)
{
/* A single 16-bit integer */
if
(
len
!=
2
)
...
...
@@ -285,7 +298,8 @@ validate_uint16(struct efi_variable *var, int match, u8 *buffer, int len)
}
static
bool
validate_ascii_string
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
int
len
)
validate_ascii_string
(
struct
efi_variable
*
var
,
int
match
,
u8
*
buffer
,
unsigned
long
len
)
{
int
i
;
...
...
@@ -303,7 +317,7 @@ validate_ascii_string(struct efi_variable *var, int match, u8 *buffer, int len)
struct
variable_validate
{
char
*
name
;
bool
(
*
validate
)(
struct
efi_variable
*
var
,
int
match
,
u8
*
data
,
int
len
);
unsigned
long
len
);
};
static
const
struct
variable_validate
variable_validate
[]
=
{
...
...
@@ -325,7 +339,7 @@ static const struct variable_validate variable_validate[] = {
};
static
bool
validate_var
(
struct
efi_variable
*
var
,
u8
*
data
,
int
len
)
validate_var
(
struct
efi_variable
*
var
,
u8
*
data
,
unsigned
long
len
)
{
int
i
;
u16
*
unicode_name
=
var
->
VariableName
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录