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
71cfd6cc
Unverified
Commit
71cfd6cc
authored
Mar 26, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string_utils: fix parse_byte_size_string()
Link:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32475
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
05eac3f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
string_utils.c
src/lxc/string_utils.c
+15
-6
No files found.
src/lxc/string_utils.c
View file @
71cfd6cc
...
@@ -906,7 +906,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
...
@@ -906,7 +906,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
suffix
[
3
]
=
{
0
};
char
suffix
[
3
]
=
{
0
};
if
(
!
s
||
strequal
(
s
,
""
))
if
(
is_empty_string
(
s
))
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
...
@@ -920,17 +920,26 @@ int parse_byte_size_string(const char *s, int64_t *converted)
...
@@ -920,17 +920,26 @@ int parse_byte_size_string(const char *s, int64_t *converted)
else
else
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
if
(
suffix_len
>
0
&&
(
end
-
2
)
==
dup
&&
!
isdigit
(
*
(
end
-
2
)))
if
(
suffix_len
>
0
)
{
return
ret_errno
(
EINVAL
);
if
((
end
-
1
)
==
dup
)
return
ret_errno
(
EINVAL
);
if
(
suffix_len
>
0
&&
isalpha
(
*
(
end
-
2
)))
if
((
end
-
2
)
==
dup
)
{
suffix_len
++
;
if
(
isalpha
(
*
(
end
-
2
)))
return
ret_errno
(
EINVAL
);
/* 1B */
}
else
{
if
(
isalpha
(
*
(
end
-
2
)))
/* 12MB */
suffix_len
++
;
/* 12B */
}
if
(
suffix_len
>
0
)
{
memcpy
(
suffix
,
end
-
suffix_len
,
suffix_len
);
memcpy
(
suffix
,
end
-
suffix_len
,
suffix_len
);
*
(
suffix
+
suffix_len
)
=
'\0'
;
*
(
suffix
+
suffix_len
)
=
'\0'
;
*
(
end
-
suffix_len
)
=
'\0'
;
*
(
end
-
suffix_len
)
=
'\0'
;
}
}
dup
[
lxc_char_right_gc
(
dup
,
strlen
(
dup
))]
=
'\0'
;
dup
[
lxc_char_right_gc
(
dup
,
strlen
(
dup
))]
=
'\0'
;
ret
=
lxc_safe_long_long
(
dup
,
&
conv
);
ret
=
lxc_safe_long_long
(
dup
,
&
conv
);
...
...
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