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
a835ed06
Commit
a835ed06
authored
Jan 04, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle date tag.
parent
a3c6acf8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
12 deletions
+43
-12
bplist.c
src/bplist.c
+33
-10
plist.h
src/plist.h
+1
-0
xplist.c
src/xplist.c
+9
-2
No files found.
src/bplist.c
View file @
a835ed06
...
@@ -74,7 +74,7 @@ static void byte_convert(uint8_t *address, size_t size)
...
@@ -74,7 +74,7 @@ static void byte_convert(uint8_t *address, size_t size)
#endif
#endif
}
}
#define
swap_n_bytes
(x, n) \
#define
UINT_TO_HOST
(x, n) \
(n == 8 ? GUINT64_FROM_BE( *(uint64_t *)(x) ) : \
(n == 8 ? GUINT64_FROM_BE( *(uint64_t *)(x) ) : \
(n == 4 ? GUINT32_FROM_BE( *(uint32_t *)(x) ) : \
(n == 4 ? GUINT32_FROM_BE( *(uint32_t *)(x) ) : \
(n == 2 ? GUINT16_FROM_BE( *(uint16_t *)(x) ) : \
(n == 2 ? GUINT16_FROM_BE( *(uint16_t *)(x) ) : \
...
@@ -104,7 +104,7 @@ static plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)
...
@@ -104,7 +104,7 @@ static plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)
case
sizeof
(
uint32_t
):
case
sizeof
(
uint32_t
):
case
sizeof
(
uint64_t
):
case
sizeof
(
uint64_t
):
memcpy
(
&
data
->
intval
,
bnode
,
size
);
memcpy
(
&
data
->
intval
,
bnode
,
size
);
data
->
intval
=
swap_n_bytes
(
&
data
->
intval
,
size
);
data
->
intval
=
UINT_TO_HOST
(
&
data
->
intval
,
size
);
break
;
break
;
default:
default:
free
(
data
);
free
(
data
);
...
@@ -124,7 +124,7 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
...
@@ -124,7 +124,7 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
switch
(
size
)
{
switch
(
size
)
{
case
sizeof
(
float
):
case
sizeof
(
float
):
case
sizeof
(
double
):
case
sizeof
(
double
):
data
->
realval
=
swap_n_bytes
(
bnode
,
size
);
data
->
intval
=
UINT_TO_HOST
(
bnode
,
size
);
//use the fact that we have an union to cheat byte swapping
break
;
break
;
default:
default:
free
(
data
);
free
(
data
);
...
@@ -134,6 +134,18 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
...
@@ -134,6 +134,18 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
static
plist_t
parse_date_node
(
char
*
bnode
,
uint8_t
size
)
{
plist_t
node
=
parse_real_node
(
bnode
,
size
);
plist_data_t
data
=
plist_get_data
(
node
);
double
time_real
=
data
->
realval
;
data
->
timeval
.
tv_sec
=
(
glong
)
time_real
;
data
->
timeval
.
tv_usec
=
(
time_real
-
(
glong
)
time_real
)
*
G_USEC_PER_SEC
;
data
->
type
=
PLIST_DATE
;
return
node
;
}
static
plist_t
parse_string_node
(
char
*
bnode
,
uint8_t
size
)
static
plist_t
parse_string_node
(
char
*
bnode
,
uint8_t
size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -241,7 +253,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec
...
@@ -241,7 +253,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec
if
(
3
!=
size
)
if
(
3
!=
size
)
return
NULL
;
return
NULL
;
else
else
return
parse_
real
_node
(
object
,
size
);
return
parse_
date
_node
(
object
,
size
);
case
BPLIST_DATA
:
case
BPLIST_DATA
:
if
(
0x0F
==
size
)
{
if
(
0x0F
==
size
)
{
...
@@ -378,7 +390,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
...
@@ -378,7 +390,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
uint64_t
current_offset
=
0
;
uint64_t
current_offset
=
0
;
const
char
*
offset_table
=
plist_bin
+
offset_table_index
;
const
char
*
offset_table
=
plist_bin
+
offset_table_index
;
for
(
i
=
0
;
i
<
num_objects
;
i
++
)
{
for
(
i
=
0
;
i
<
num_objects
;
i
++
)
{
current_offset
=
swap_n_bytes
(
offset_table
+
i
*
offset_size
,
offset_size
);
current_offset
=
UINT_TO_HOST
(
offset_table
+
i
*
offset_size
,
offset_size
);
log_debug_msg
(
"parse_nodes: current_offset = %i
\n
"
,
current_offset
);
log_debug_msg
(
"parse_nodes: current_offset = %i
\n
"
,
current_offset
);
char
*
obj
=
plist_bin
+
current_offset
;
char
*
obj
=
plist_bin
+
current_offset
;
...
@@ -402,8 +414,8 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
...
@@ -402,8 +414,8 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
str_i
=
j
*
dict_param_size
;
str_i
=
j
*
dict_param_size
;
str_j
=
(
j
+
data
->
length
)
*
dict_param_size
;
str_j
=
(
j
+
data
->
length
)
*
dict_param_size
;
index1
=
swap_n_bytes
(
data
->
buff
+
str_i
,
dict_param_size
);
index1
=
UINT_TO_HOST
(
data
->
buff
+
str_i
,
dict_param_size
);
index2
=
swap_n_bytes
(
data
->
buff
+
str_j
,
dict_param_size
);
index2
=
UINT_TO_HOST
(
data
->
buff
+
str_j
,
dict_param_size
);
//first one is actually a key
//first one is actually a key
plist_get_data
(
nodeslist
[
index1
])
->
type
=
PLIST_KEY
;
plist_get_data
(
nodeslist
[
index1
])
->
type
=
PLIST_KEY
;
...
@@ -430,7 +442,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
...
@@ -430,7 +442,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
log_debug_msg
(
"parse_nodes: array found
\n
"
);
log_debug_msg
(
"parse_nodes: array found
\n
"
);
for
(
j
=
0
;
j
<
data
->
length
;
j
++
)
{
for
(
j
=
0
;
j
<
data
->
length
;
j
++
)
{
str_j
=
j
*
dict_param_size
;
str_j
=
j
*
dict_param_size
;
index1
=
swap_n_bytes
(
data
->
buff
+
str_j
,
dict_param_size
);
index1
=
UINT_TO_HOST
(
data
->
buff
+
str_j
,
dict_param_size
);
if
(
index1
<
num_objects
)
{
if
(
index1
<
num_objects
)
{
if
(
G_NODE_IS_ROOT
(
nodeslist
[
index1
]))
if
(
G_NODE_IS_ROOT
(
nodeslist
[
index1
]))
...
@@ -463,7 +475,7 @@ static guint plist_data_hash(gconstpointer key)
...
@@ -463,7 +475,7 @@ static guint plist_data_hash(gconstpointer key)
case
PLIST_BOOLEAN
:
case
PLIST_BOOLEAN
:
case
PLIST_UINT
:
case
PLIST_UINT
:
case
PLIST_REAL
:
case
PLIST_REAL
:
buff
=
(
char
*
)
&
data
->
intval
;
buff
=
(
char
*
)
&
data
->
intval
;
//works also for real as we use an union
size
=
8
;
size
=
8
;
break
;
break
;
case
PLIST_KEY
:
case
PLIST_KEY
:
...
@@ -604,6 +616,17 @@ static void write_real(GByteArray * bplist, double val)
...
@@ -604,6 +616,17 @@ static void write_real(GByteArray * bplist, double val)
free
(
buff
);
free
(
buff
);
}
}
static
void
write_date
(
GByteArray
*
bplist
,
double
val
)
{
uint64_t
size
=
8
;
//dates always use 8 bytes
uint8_t
*
buff
=
(
uint8_t
*
)
malloc
(
sizeof
(
uint8_t
)
+
size
);
buff
[
0
]
=
BPLIST_DATE
|
Log2
(
size
);
memcpy
(
buff
+
1
,
&
val
,
size
);
byte_convert
(
buff
+
1
,
size
);
g_byte_array_append
(
bplist
,
buff
,
sizeof
(
uint8_t
)
+
size
);
free
(
buff
);
}
static
void
write_raw_data
(
GByteArray
*
bplist
,
uint8_t
mark
,
uint8_t
*
val
,
uint64_t
size
)
static
void
write_raw_data
(
GByteArray
*
bplist
,
uint8_t
mark
,
uint8_t
*
val
,
uint64_t
size
)
{
{
uint8_t
marker
=
mark
|
(
size
<
15
?
size
:
0xf
);
uint8_t
marker
=
mark
|
(
size
<
15
?
size
:
0xf
);
...
@@ -764,7 +787,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
...
@@ -764,7 +787,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
write_dict
(
bplist_buff
,
g_ptr_array_index
(
objects
,
i
),
ref_table
,
dict_param_size
);
write_dict
(
bplist_buff
,
g_ptr_array_index
(
objects
,
i
),
ref_table
,
dict_param_size
);
break
;
break
;
case
PLIST_DATE
:
case
PLIST_DATE
:
//TODO
write_date
(
bplist_buff
,
data
->
timeval
.
tv_sec
+
(
double
)
data
->
timeval
.
tv_usec
/
G_USEC_PER_SEC
);
break
;
break
;
default:
default:
break
;
break
;
...
...
src/plist.h
View file @
a835ed06
...
@@ -44,6 +44,7 @@ struct plist_data_s {
...
@@ -44,6 +44,7 @@ struct plist_data_s {
char
*
strval
;
char
*
strval
;
wchar_t
*
unicodeval
;
wchar_t
*
unicodeval
;
uint8_t
*
buff
;
uint8_t
*
buff
;
GTimeVal
timeval
;
};
};
uint64_t
length
;
uint64_t
length
;
plist_type
type
;
plist_type
type
;
...
...
src/xplist.c
View file @
a835ed06
...
@@ -188,7 +188,10 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
...
@@ -188,7 +188,10 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
tag
=
XPLIST_DICT
;
tag
=
XPLIST_DICT
;
isStruct
=
TRUE
;
isStruct
=
TRUE
;
break
;
break
;
case
PLIST_DATE
:
//TODO : handle date tag
case
PLIST_DATE
:
tag
=
XPLIST_DATE
;
val
=
g_time_val_to_iso8601
(
&
node_data
->
timeval
);
break
;
default:
default:
break
;
break
;
}
}
...
@@ -268,8 +271,12 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
...
@@ -268,8 +271,12 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
continue
;
}
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATE
))
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATE
))
{
g_time_val_from_iso8601
((
char
*
)
xmlNodeGetContent
(
node
),
&
data
->
timeval
);
data
->
type
=
PLIST_DATE
;
data
->
length
=
sizeof
(
GTimeVal
);
continue
;
//TODO : handle date tag
continue
;
//TODO : handle date tag
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_STRING
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_STRING
))
{
data
->
strval
=
strdup
(
(
char
*
)
xmlNodeGetContent
(
node
));
data
->
strval
=
strdup
(
(
char
*
)
xmlNodeGetContent
(
node
));
...
...
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