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
501f8c86
Commit
501f8c86
authored
4 years ago
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plistutil: Fix stdin input buffer reallocation
parent
ced16994
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
plistutil.c
tools/plistutil.c
+16
-5
No files found.
tools/plistutil.c
View file @
501f8c86
...
...
@@ -34,8 +34,6 @@
#include <errno.h>
#include <unistd.h>
#define BUF_SIZE 2048 // Seems to be a decent start to cover most stdin files
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
...
...
@@ -147,6 +145,7 @@ int main(int argc, char *argv[])
char
*
plist_out
=
NULL
;
uint32_t
size
=
0
;
int
read_size
=
0
;
int
read_capacity
=
4096
;
char
*
plist_entire
=
NULL
;
struct
stat
filestats
;
options_t
*
options
=
parse_arguments
(
argc
,
argv
);
...
...
@@ -160,7 +159,7 @@ int main(int argc, char *argv[])
if
(
!
options
->
in_file
||
!
strcmp
(
options
->
in_file
,
"-"
))
{
read_size
=
0
;
plist_entire
=
malloc
(
sizeof
(
char
)
*
BUF_SIZE
);
plist_entire
=
malloc
(
sizeof
(
char
)
*
read_capacity
);
if
(
plist_entire
==
NULL
)
{
printf
(
"ERROR: Failed to allocate buffer to read from stdin"
);
...
...
@@ -171,9 +170,10 @@ int main(int argc, char *argv[])
char
ch
;
while
(
read
(
STDIN_FILENO
,
&
ch
,
1
)
>
0
)
{
if
(
read_size
>=
BUF_SIZE
)
{
if
(
read_size
>=
read_capacity
)
{
char
*
old
=
plist_entire
;
plist_entire
=
realloc
(
plist_entire
,
sizeof
(
char
)
*
(
read_size
+
1
));
read_capacity
+=
4096
;
plist_entire
=
realloc
(
plist_entire
,
sizeof
(
char
)
*
read_capacity
);
if
(
plist_entire
==
NULL
)
{
printf
(
"ERROR: Failed to reallocate stdin buffer
\n
"
);
...
...
@@ -185,6 +185,17 @@ int main(int argc, char *argv[])
plist_entire
[
read_size
]
=
ch
;
read_size
++
;
}
if
(
read_size
>=
read_capacity
)
{
char
*
old
=
plist_entire
;
plist_entire
=
realloc
(
plist_entire
,
sizeof
(
char
)
*
(
read_capacity
+
1
));
if
(
plist_entire
==
NULL
)
{
printf
(
"ERROR: Failed to reallocate stdin buffer
\n
"
);
free
(
old
);
free
(
options
);
return
1
;
}
}
plist_entire
[
read_size
]
=
'\0'
;
// Not positive we need this, but it doesnt seem to hurt lol
...
...
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