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
962d4064
Commit
962d4064
authored
Jan 28, 2017
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bplist: Improve writing of integer nodes
parent
458341fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
bplist.c
src/bplist.c
+12
-21
No files found.
src/bplist.c
View file @
962d4064
...
...
@@ -837,36 +837,27 @@ static void serialize_plist(node_t* node, void* data)
static
void
write_int
(
bytearray_t
*
bplist
,
uint64_t
val
)
{
uint64_
t
size
=
get_needed_bytes
(
val
);
uint8_t
*
buff
=
NULL
;
in
t
size
=
get_needed_bytes
(
val
);
uint8_t
sz
;
//do not write 3bytes int node
if
(
size
==
3
)
size
++
;
sz
=
BPLIST_UINT
|
Log2
(
size
);
#ifdef __BIG_ENDIAN__
val
=
val
<<
((
sizeof
(
uint64_t
)
-
size
)
*
8
);
#endif
buff
=
(
uint8_t
*
)
malloc
(
sizeof
(
uint8_t
)
+
size
);
buff
[
0
]
=
BPLIST_UINT
|
Log2
(
size
);
memcpy
(
buff
+
1
,
&
val
,
size
);
byte_convert
(
buff
+
1
,
size
);
byte_array_append
(
bplist
,
buff
,
sizeof
(
uint8_t
)
+
size
);
free
(
buff
);
val
=
be64toh
(
val
);
byte_array_append
(
bplist
,
&
sz
,
1
);
byte_array_append
(
bplist
,
(
uint8_t
*
)
&
val
+
(
8
-
size
),
size
);
}
static
void
write_uint
(
bytearray_t
*
bplist
,
uint64_t
val
)
{
uint
64_t
size
=
16
;
uint
8_t
*
buff
=
NULL
;
uint
8_t
sz
=
BPLIST_UINT
|
4
;
uint
64_t
zero
=
0
;
buff
=
(
uint8_t
*
)
malloc
(
sizeof
(
uint8_t
)
+
size
);
buff
[
0
]
=
BPLIST_UINT
|
4
;
memset
(
buff
+
1
,
'\0'
,
8
);
memcpy
(
buff
+
9
,
&
val
,
8
);
byte_convert
(
buff
+
9
,
8
);
byte_array_append
(
bplist
,
buff
,
sizeof
(
uint8_t
)
+
size
);
free
(
buff
);
val
=
be64toh
(
val
);
byte_array_append
(
bplist
,
&
sz
,
1
);
byte_array_append
(
bplist
,
&
zero
,
sizeof
(
uint64_t
));
byte_array_append
(
bplist
,
&
val
,
sizeof
(
uint64_t
));
}
static
void
write_real
(
bytearray_t
*
bplist
,
double
val
)
...
...
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