Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
97176c63
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
97176c63
编写于
4月 03, 2011
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virt-aa-helper: Remove PATH_MAX sized stack allocations
上级
859efe7f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
18 deletion
+28
-18
src/security/virt-aa-helper.c
src/security/virt-aa-helper.c
+28
-18
未找到文件。
src/security/virt-aa-helper.c
浏览文件 @
97176c63
...
...
@@ -188,8 +188,9 @@ replace_string(char *orig, const size_t len, const char *oldstr,
static
int
parserCommand
(
const
char
*
profile_name
,
const
char
cmd
)
{
int
result
=
-
1
;
char
flag
[
3
];
char
profile
[
PATH_MAX
]
;
char
*
profile
;
int
status
;
int
ret
;
...
...
@@ -200,15 +201,15 @@ parserCommand(const char *profile_name, const char cmd)
snprintf
(
flag
,
3
,
"-%c"
,
cmd
);
if
(
snprintf
(
profile
,
PATH_MAX
,
"%s/%s"
,
APPARMOR_DIR
"/libvirt"
,
profile_name
)
>
PATH_MAX
-
1
)
{
if
(
virAsprintf
(
&
profile
,
"%s/%s"
,
APPARMOR_DIR
"/libvirt"
,
profile_name
)
<
0
)
{
vah_error
(
NULL
,
0
,
_
(
"profile name exceeds maximum length"
));
return
-
1
;
}
if
(
!
virFileExists
(
profile
))
{
vah_error
(
NULL
,
0
,
_
(
"profile does not exist"
));
return
-
1
;
goto
cleanup
;
}
else
{
const
char
*
const
argv
[]
=
{
"/sbin/apparmor_parser"
,
flag
,
profile
,
NULL
...
...
@@ -217,18 +218,23 @@ parserCommand(const char *profile_name, const char cmd)
(
WIFEXITED
(
status
)
&&
WEXITSTATUS
(
status
)
!=
0
))
{
if
(
ret
!=
0
)
{
vah_error
(
NULL
,
0
,
_
(
"failed to run apparmor_parser"
));
return
-
1
;
goto
cleanup
;
}
else
if
(
cmd
==
'R'
&&
WIFEXITED
(
status
)
&&
WEXITSTATUS
(
status
)
==
234
)
{
vah_warning
(
_
(
"unable to unload already unloaded profile"
));
}
else
{
vah_error
(
NULL
,
0
,
_
(
"apparmor_parser exited with error"
));
return
-
1
;
goto
cleanup
;
}
}
}
return
0
;
result
=
0
;
cleanup:
VIR_FREE
(
profile
);
return
result
;
}
/*
...
...
@@ -308,7 +314,7 @@ static int
create_profile
(
const
char
*
profile
,
const
char
*
profile_name
,
const
char
*
profile_files
)
{
char
template
[
PATH_MAX
]
;
char
*
template
;
char
*
tcontent
=
NULL
;
char
*
pcontent
=
NULL
;
char
*
replace_name
=
NULL
;
...
...
@@ -324,8 +330,7 @@ create_profile(const char *profile, const char *profile_name,
goto
end
;
}
if
(
snprintf
(
template
,
PATH_MAX
,
"%s/TEMPLATE"
,
APPARMOR_DIR
"/libvirt"
)
>
PATH_MAX
-
1
)
{
if
(
virAsprintf
(
&
template
,
"%s/TEMPLATE"
,
APPARMOR_DIR
"/libvirt"
)
<
0
)
{
vah_error
(
NULL
,
0
,
_
(
"template name exceeds maximum length"
));
goto
end
;
}
...
...
@@ -409,6 +414,7 @@ create_profile(const char *profile, const char *profile_name,
clean_tcontent:
VIR_FREE
(
tcontent
);
end:
VIR_FREE
(
template
);
return
rc
;
}
...
...
@@ -1134,8 +1140,8 @@ main(int argc, char **argv)
vahControl
_ctl
,
*
ctl
=
&
_ctl
;
virBuffer
buf
=
VIR_BUFFER_INITIALIZER
;
int
rc
=
-
1
;
char
profile
[
PATH_MAX
]
;
char
include_file
[
PATH_MAX
]
;
char
*
profile
=
NULL
;
char
*
include_file
=
NULL
;
if
(
setlocale
(
LC_ALL
,
""
)
==
NULL
||
bindtextdomain
(
PACKAGE
,
LOCALEDIR
)
==
NULL
||
...
...
@@ -1164,13 +1170,13 @@ main(int argc, char **argv)
if
(
vahParseArgv
(
ctl
,
argc
,
argv
)
!=
0
)
vah_error
(
ctl
,
1
,
_
(
"could not parse arguments"
));
if
(
snprintf
(
profile
,
PATH_MAX
,
"%s/%s"
,
APPARMOR_DIR
"/libvirt"
,
ctl
->
uuid
)
>
PATH_MAX
-
1
)
vah_error
(
ctl
,
1
,
_
(
"profile name exceeds maximum length
"
));
if
(
virAsprintf
(
&
profile
,
"%s/%s"
,
APPARMOR_DIR
"/libvirt"
,
ctl
->
uuid
)
<
0
)
vah_error
(
ctl
,
0
,
_
(
"could not allocate memory
"
));
if
(
snprintf
(
include_file
,
PATH_MAX
,
"%s/%s.files"
,
APPARMOR_DIR
"/libvirt"
,
ctl
->
uuid
)
>
PATH_MAX
-
1
)
vah_error
(
ctl
,
1
,
_
(
"disk profile name exceeds maximum length
"
));
if
(
virAsprintf
(
&
include_file
,
"%s/%s.files"
,
APPARMOR_DIR
"/libvirt"
,
ctl
->
uuid
)
<
0
)
vah_error
(
ctl
,
0
,
_
(
"could not allocate memory
"
));
if
(
ctl
->
cmd
==
'a'
)
rc
=
parserLoad
(
ctl
->
uuid
);
...
...
@@ -1258,5 +1264,9 @@ main(int argc, char **argv)
}
vahDeinit
(
ctl
);
VIR_FREE
(
profile
);
VIR_FREE
(
include_file
);
exit
(
rc
==
0
?
EXIT_SUCCESS
:
EXIT_FAILURE
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录