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
bd6ce883
Commit
bd6ce883
authored
Jul 29, 2010
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unicode binary writing.
parent
a1ced5fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
bplist.c
src/bplist.c
+23
-7
No files found.
src/bplist.c
View file @
bd6ce883
...
...
@@ -25,6 +25,7 @@
#include <string.h>
#include <libxml/encoding.h>
#include <ctype.h>
#include <plist/plist.h>
#include "plist.h"
...
...
@@ -732,6 +733,8 @@ static void write_raw_data(GByteArray * bplist, uint8_t mark, uint8_t * val, uin
g_byte_array_append
(
bplist
,
int_buff
->
data
,
int_buff
->
len
);
g_byte_array_free
(
int_buff
,
TRUE
);
}
//stupid unicode buffer length
if
(
BPLIST_UNICODE
==
mark
)
size
*=
2
;
buff
=
(
uint8_t
*
)
malloc
(
size
);
memcpy
(
buff
,
val
,
size
);
g_byte_array_append
(
bplist
,
buff
,
size
);
...
...
@@ -757,7 +760,7 @@ static void write_unicode(GByteArray * bplist, gunichar2 * val, uint64_t size)
memcpy
(
buff
,
val
,
size2
);
for
(
i
=
0
;
i
<
size
;
i
++
)
byte_convert
(
buff
+
i
*
sizeof
(
gunichar2
),
sizeof
(
gunichar2
));
write_raw_data
(
bplist
,
BPLIST_
STRING
,
buff
,
size2
);
write_raw_data
(
bplist
,
BPLIST_
UNICODE
,
buff
,
size
);
}
static
void
write_array
(
GByteArray
*
bplist
,
GNode
*
node
,
GHashTable
*
ref_table
,
uint8_t
dict_param_size
)
...
...
@@ -842,6 +845,20 @@ static void write_dict(GByteArray * bplist, GNode * node, GHashTable * ref_table
}
static
int
is_ascii_string
(
char
*
s
,
int
len
)
{
int
ret
=
1
,
i
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
isascii
(
s
[
i
]
)
)
{
ret
=
0
;
break
;
}
}
return
ret
;
}
void
plist_to_bin
(
plist_t
plist
,
char
**
plist_bin
,
uint32_t
*
length
)
{
GPtrArray
*
objects
=
NULL
;
...
...
@@ -922,17 +939,16 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
case
PLIST_KEY
:
case
PLIST_STRING
:
len
=
strlen
(
data
->
strval
);
type
=
xmlDetectCharEncoding
((
const
unsigned
char
*
)
data
->
strval
,
len
);
if
(
XML_CHAR_ENCODING_UTF8
==
type
)
if
(
is_ascii_string
(
data
->
strval
,
len
)
)
{
write_string
(
bplist_buff
,
data
->
strval
);
}
else
{
unicodestr
=
g_utf8_to_utf16
(
data
->
strval
,
len
,
&
items_read
,
&
items_written
,
&
error
);
write_unicode
(
bplist_buff
,
unicodestr
,
items_written
);
g_free
(
unicodestr
);
}
else
if
(
XML_CHAR_ENCODING_ASCII
==
type
||
XML_CHAR_ENCODING_NONE
==
type
)
{
write_string
(
bplist_buff
,
data
->
strval
);
}
break
;
case
PLIST_DATA
:
write_data
(
bplist_buff
,
data
->
buff
,
data
->
length
);
...
...
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