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
ae8b7a0f
Commit
ae8b7a0f
authored
8 years ago
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base64: Prevent use of strlen() in base64decode when input buffer size is known
parent
5e8fb617
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
base64.c
src/base64.c
+8
-7
No files found.
src/base64.c
View file @
ae8b7a0f
...
@@ -105,22 +105,23 @@ static int base64decode_block(unsigned char *target, const char *data, size_t da
...
@@ -105,22 +105,23 @@ static int base64decode_block(unsigned char *target, const char *data, size_t da
unsigned
char
*
base64decode
(
const
char
*
buf
,
size_t
*
size
)
unsigned
char
*
base64decode
(
const
char
*
buf
,
size_t
*
size
)
{
{
if
(
!
buf
)
return
NULL
;
if
(
!
buf
||
!
size
)
return
NULL
;
size_t
len
=
strlen
(
buf
);
size_t
len
=
(
*
size
>
0
)
?
*
size
:
strlen
(
buf
);
if
(
len
<=
0
)
return
NULL
;
if
(
len
<=
0
)
return
NULL
;
unsigned
char
*
outbuf
=
(
unsigned
char
*
)
malloc
((
len
/
4
)
*
3
+
3
);
unsigned
char
*
outbuf
=
(
unsigned
char
*
)
malloc
((
len
/
4
)
*
3
+
3
);
const
char
*
ptr
=
buf
;
const
char
*
ptr
=
buf
;
int
p
=
0
;
int
p
=
0
;
size_t
l
=
0
;
do
{
do
{
ptr
+=
strspn
(
ptr
,
"
\r\n\t
"
);
ptr
+=
strspn
(
ptr
,
"
\r\n\t
"
);
if
(
*
ptr
==
'\0'
)
{
if
(
*
ptr
==
'\0'
||
ptr
>=
buf
+
len
)
{
break
;
break
;
}
}
l
en
=
strcspn
(
ptr
,
"
\r\n\t
"
);
l
=
strcspn
(
ptr
,
"
\r\n\t
"
);
if
(
l
en
>
3
)
{
if
(
l
>
3
&&
ptr
+
l
<=
buf
+
len
)
{
p
+=
base64decode_block
(
outbuf
+
p
,
ptr
,
l
en
);
p
+=
base64decode_block
(
outbuf
+
p
,
ptr
,
l
);
ptr
+=
l
en
;
ptr
+=
l
;
}
else
{
}
else
{
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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