... | ... |
@@ -714,7 +714,7 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
714 | 714 |
name = get_property_name2(prop_block[idx].name, prop_block[idx].name_size); |
715 | 715 |
if (name) { |
716 | 716 |
if (!strcmp(name, "_xmlsignatures") || !strcmp(name, "_signatures")) { |
717 |
- cli_jsonbool(ctx->wrkproperty, "DigitalSignatures", 1); |
|
717 |
+ cli_jsonbool(ctx->wrkproperty, "HasDigitalSignatures", 1); |
|
718 | 718 |
} |
719 | 719 |
free(name); |
720 | 720 |
} |
... | ... |
@@ -897,7 +897,7 @@ handler_writefile(ole2_header_t * hdr, property_t * prop, const char *dir, cli_c |
897 | 897 |
static int |
898 | 898 |
handler_enum(ole2_header_t * hdr, property_t * prop, const char *dir, cli_ctx * ctx) |
899 | 899 |
{ |
900 |
- char *name; |
|
900 |
+ char *name = NULL; |
|
901 | 901 |
#if HAVE_JSON |
902 | 902 |
json_object *arrobj, *strmobj; |
903 | 903 |
|
... | ... |
@@ -924,24 +924,19 @@ handler_enum(ole2_header_t * hdr, property_t * prop, const char *dir, cli_ctx * |
924 | 924 |
} |
925 | 925 |
|
926 | 926 |
} |
927 |
- |
|
928 |
- if (!hdr->has_vba) { |
|
927 |
+ } |
|
928 |
+#endif |
|
929 |
+ if (!hdr->has_vba) { |
|
930 |
+ if (!name) |
|
931 |
+ name = get_property_name2(prop->name, prop->name_size); |
|
932 |
+ if (name) { |
|
929 | 933 |
if (!strcmp(name, "_vba_project") || !strcmp(name, "powerpoint document") || !strcmp(name, "worddocument") || !strcmp(name, "_1_ole10native")) |
930 | 934 |
hdr->has_vba = 1; |
931 | 935 |
} |
932 |
- free(name); |
|
933 | 936 |
} |
934 |
-#else |
|
935 |
- if (!hdr->has_vba) { |
|
936 |
- name = get_property_name2(prop->name, prop->name_size); |
|
937 |
- if (name) { |
|
938 |
- if (!strcmp(name, "_vba_project") || !strcmp(name, "powerpoint document") || !strcmp(name, "worddocument") || !strcmp(name, "_1_ole10native")) |
|
939 |
- hdr->has_vba = 1; |
|
940 |
- free(name); |
|
941 |
- } |
|
942 |
- } |
|
943 |
-#endif |
|
944 | 937 |
|
938 |
+ if (name) |
|
939 |
+ free(name) |
|
945 | 940 |
return CL_SUCCESS; |
946 | 941 |
} |
947 | 942 |
|
... | ... |
@@ -73,6 +73,9 @@ static int ooxml_parse_value(json_object *wrkptr, const char *arrname, const xml |
73 | 73 |
int val; |
74 | 74 |
|
75 | 75 |
arrobj = cli_jsonarray(wrkptr, arrname); |
76 |
+ if (arrobj == NULL) { |
|
77 |
+ return CL_EMEM; |
|
78 |
+ } |
|
76 | 79 |
|
77 | 80 |
if (ooxml_is_int(node_value, xmlStrlen(node_value), &val)) { |
78 | 81 |
newobj = json_object_new_int(val); |
... | ... |
@@ -253,12 +256,15 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
253 | 253 |
} |
254 | 254 |
cli_dbgmsg("ooxml_parse_element: generated json object [%s]\n", element_tag); |
255 | 255 |
|
256 |
+ if (rlvl == 0) |
|
257 |
+ root = thisjobj; |
|
258 |
+ |
|
256 | 259 |
/* handle attributes */ |
257 | 260 |
if (xmlTextReaderHasAttributes(reader) == 1) { |
258 | 261 |
json_object *attributes; |
259 | 262 |
|
260 | 263 |
attributes = cli_jsonobj(thisjobj, "Attributes"); |
261 |
- if (!thisjobj) { |
|
264 |
+ if (!attributes) { |
|
262 | 265 |
return CL_EPARSE; |
263 | 266 |
} |
264 | 267 |
cli_dbgmsg("ooxml_parse_element: retrieved json object [Attributes]\n"); |
... | ... |
@@ -275,6 +281,11 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
275 | 275 |
} |
276 | 276 |
} |
277 | 277 |
|
278 |
+ if (xmlTextReaderIsEmptyElement(reader)) { |
|
279 |
+ xmlTextReaderNext(reader); |
|
280 |
+ return CL_SUCCESS; |
|
281 |
+ } |
|
282 |
+ |
|
278 | 283 |
/* advance to first content node */ |
279 | 284 |
if (xmlTextReaderRead(reader) != 1) |
280 | 285 |
return CL_EPARSE; |
... | ... |
@@ -288,9 +299,6 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
288 | 288 |
node_type = xmlTextReaderNodeType(reader); |
289 | 289 |
switch (node_type) { |
290 | 290 |
case XML_READER_TYPE_ELEMENT: |
291 |
- if (rlvl == 0) |
|
292 |
- root = thisjobj; |
|
293 |
- |
|
294 | 291 |
ret = ooxml_parse_element(ctx, reader, thisjobj, rlvl+1, root); |
295 | 292 |
if (ret != CL_SUCCESS) { |
296 | 293 |
return ret; |
... | ... |
@@ -344,7 +352,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
344 | 344 |
|
345 | 345 |
cli_dbgmsg("ooxml_parse_element: unhandled xml node %s [%d]: %s\n", node_name, node_type, node_value); |
346 | 346 |
#endif |
347 |
- return CL_EPARSE; |
|
347 |
+ xmlTextReaderNext(reader); |
|
348 |
+ return CL_SUCCESS; |
|
348 | 349 |
} |
349 | 350 |
} |
350 | 351 |
|
... | ... |
@@ -371,6 +380,9 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx) |
371 | 371 |
|
372 | 372 |
ret = ooxml_parse_element(ctx, reader, ctx->wrkproperty, 0, NULL); |
373 | 373 |
|
374 |
+ if (ret != CL_SUCCESS && ret != CL_ETIMEOUT) |
|
375 |
+ cli_jsonbool(ctx->wrkproperty, "ParseError", 1); |
|
376 |
+ |
|
374 | 377 |
xmlTextReaderClose(reader); |
375 | 378 |
xmlFreeTextReader(reader); |
376 | 379 |
return ret; |