Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
pwn
libplist
Commits
fdebf8b3
Commit
fdebf8b3
authored
Apr 19, 2017
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bplist: Fix integer overflow check (offset table size)
parent
415c35a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
bplist.c
src/bplist.c
+17
-3
No files found.
src/bplist.c
View file @
fdebf8b3
...
...
@@ -178,6 +178,19 @@ union plist_uint_ptr
#define float_bswap32(x) (x)
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#if __has_builtin(__builtin_umulll_overflow) || __GNUC__ >= 5
#define uint64_mul_overflow(a, b, r) __builtin_umulll_overflow(a, b, r)
#else
static
int
uint64_mul_overflow
(
uint64_t
a
,
uint64_t
b
,
uint64_t
*
res
)
{
*
res
=
a
*
b
;
return
(
a
>
UINT64_MAX
/
b
);
}
#endif
#define NODE_IS_ROOT(x) (((node_t*)x)->isRoot)
...
...
@@ -773,6 +786,7 @@ PLIST_API void plist_from_bin(const char *plist_bin, uint32_t length, plist_t *
uint64_t
num_objects
=
0
;
uint64_t
root_object
=
0
;
const
char
*
offset_table
=
NULL
;
uint64_t
offset_table_size
=
0
;
const
char
*
start_data
=
NULL
;
const
char
*
end_data
=
NULL
;
...
...
@@ -829,12 +843,12 @@ PLIST_API void plist_from_bin(const char *plist_bin, uint32_t length, plist_t *
return
;
}
if
(
num_objects
*
offset_size
<
num_objects
)
{
PLIST_BIN_ERR
(
"integer overflow when calculating offset table size
(too many objects)
\n
"
);
if
(
uint64_mul_overflow
(
num_objects
,
offset_size
,
&
offset_table_size
)
)
{
PLIST_BIN_ERR
(
"integer overflow when calculating offset table size
\n
"
);
return
;
}
if
((
uint64_t
)
offset_table
+
num_objects
*
offset_size
>
(
uint64_t
)
end_data
)
{
if
((
offset_table
+
offset_table_size
<
offset_table
)
||
(
offset_table
+
offset_table_size
>
end_data
)
)
{
PLIST_BIN_ERR
(
"offset table points outside of valid range
\n
"
);
return
;
}
...
...
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