Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
cf223131
Unverified
Commit
cf223131
authored
Dec 06, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverity: #1425739
check snprintf() return value Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
5384511c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
snapshot.c
src/tests/snapshot.c
+10
-7
No files found.
src/tests/snapshot.c
View file @
cf223131
...
...
@@ -55,6 +55,10 @@ static void try_to_remove(void)
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
n
,
ret
;
char
path
[
1024
];
struct
stat
sb
;
struct
lxc_snapshot
*
s
;
struct
lxc_container
*
c
,
*
c2
=
NULL
;
char
*
template
=
"busybox"
;
...
...
@@ -89,19 +93,18 @@ int main(int argc, char *argv[])
}
// rootfs should be ${lxcpath}${lxcname}/snaps/snap0/rootfs
struct
stat
sb
;
int
ret
;
char
path
[
1024
];
snprintf
(
path
,
1024
,
"%s/%s/snaps/snap0/rootfs"
,
lxc_get_global_config_item
(
"lxc.lxcpath"
),
MYNAME
);
ret
=
snprintf
(
path
,
1024
,
"%s/%s/snaps/snap0/rootfs"
,
lxc_get_global_config_item
(
"lxc.lxcpath"
),
MYNAME
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
1024
)
{
fprintf
(
stderr
,
"%s: %d: failed to create string
\n
"
,
__FILE__
,
__LINE__
);
goto
err
;
}
ret
=
stat
(
path
,
&
sb
);
if
(
ret
!=
0
)
{
fprintf
(
stderr
,
"%s: %d: snapshot was not actually created
\n
"
,
__FILE__
,
__LINE__
);
goto
err
;
}
struct
lxc_snapshot
*
s
;
int
i
,
n
;
n
=
c
->
snapshot_list
(
c
,
&
s
);
if
(
n
<
1
)
{
fprintf
(
stderr
,
"%s: %d: failed listing containers
\n
"
,
__FILE__
,
__LINE__
);
...
...
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