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
49f6cf17
Unverified
Commit
49f6cf17
authored
Dec 09, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverity: #1425870
check snprintf() return value Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
357d2b3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
lxc_top.c
src/lxc/tools/lxc_top.c
+9
-4
No files found.
src/lxc/tools/lxc_top.c
View file @
49f6cf17
...
...
@@ -206,21 +206,26 @@ static void sig_handler(int sig)
static
void
size_humanize
(
unsigned
long
long
val
,
char
*
buf
,
size_t
bufsz
)
{
int
ret
;
if
(
val
>
1
<<
30
)
{
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
(
unsigned
int
)(
val
>>
30
),
(
unsigned
int
)(
val
&
((
1
<<
30
)
-
1
))
/
10737419
);
}
else
if
(
val
>
1
<<
20
)
{
unsigned
int
x
=
val
+
5243
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
x
>>
20
,
((
x
&
((
1
<<
20
)
-
1
))
*
100
)
>>
20
);
}
else
if
(
val
>
1
<<
10
)
{
unsigned
int
x
=
val
+
5
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
x
>>
10
,
((
x
&
((
1
<<
10
)
-
1
))
*
100
)
>>
10
);
}
else
{
snprintf
(
buf
,
bufsz
,
"%3u.00 "
,
(
unsigned
int
)
val
);
ret
=
snprintf
(
buf
,
bufsz
,
"%3u.00 "
,
(
unsigned
int
)
val
);
}
if
(
ret
<
0
||
(
size_t
)
ret
>=
bufsz
)
fprintf
(
stderr
,
"Failed to create string
\n
"
);
}
static
uint64_t
stat_get_int
(
struct
lxc_container
*
c
,
const
char
*
item
)
...
...
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