...
|
...
|
@@ -381,60 +381,62 @@ static int hwp5_cb(void *cbdata, int fd, cli_ctx *ctx)
|
381
|
381
|
|
382
|
382
|
int cli_scanhwp5_stream(cli_ctx *ctx, hwp5_header_t *hwp5, char *name, int fd)
|
383
|
383
|
{
|
384
|
|
- hwp5_debug("HWP5.x: NAME: %s\n", name);
|
|
384
|
+ hwp5_debug("HWP5.x: NAME: %s\n", name ? name : "(NULL)");
|
385
|
385
|
|
386
|
386
|
if (fd < 0) {
|
387
|
387
|
cli_errmsg("HWP5.x: Invalid file descriptor argument\n");
|
388
|
388
|
return CL_ENULLARG;
|
389
|
389
|
}
|
390
|
390
|
|
391
|
|
- /* encrypted and compressed streams */
|
392
|
|
- if (!strncmp(name, "bin", 3) || !strncmp(name, "jscriptversion", 14) ||
|
393
|
|
- !strncmp(name, "defaultjscript", 14) || !strncmp(name, "section", 7) ||
|
394
|
|
- !strncmp(name, "viewtext", 8) || !strncmp(name, "docinfo", 7)) {
|
|
391
|
+ if (name) {
|
|
392
|
+ /* encrypted and compressed streams */
|
|
393
|
+ if (!strncmp(name, "bin", 3) || !strncmp(name, "jscriptversion", 14) ||
|
|
394
|
+ !strncmp(name, "defaultjscript", 14) || !strncmp(name, "section", 7) ||
|
|
395
|
+ !strncmp(name, "viewtext", 8) || !strncmp(name, "docinfo", 7)) {
|
395
|
396
|
|
396
|
|
- if (hwp5->flags & HWP5_PASSWORD) {
|
397
|
|
- cli_dbgmsg("HWP5.x: Password encrypted stream, scanning as-is\n");
|
398
|
|
- return cli_magic_scandesc(fd, ctx);
|
399
|
|
- }
|
|
397
|
+ if (hwp5->flags & HWP5_PASSWORD) {
|
|
398
|
+ cli_dbgmsg("HWP5.x: Password encrypted stream, scanning as-is\n");
|
|
399
|
+ return cli_magic_scandesc(fd, ctx);
|
|
400
|
+ }
|
400
|
401
|
|
401
|
|
- if (hwp5->flags & HWP5_COMPRESSED) {
|
402
|
|
- /* DocInfo JSON Handling */
|
403
|
|
- STATBUF statbuf;
|
404
|
|
- fmap_t *input;
|
405
|
|
- int ret;
|
|
402
|
+ if (hwp5->flags & HWP5_COMPRESSED) {
|
|
403
|
+ /* DocInfo JSON Handling */
|
|
404
|
+ STATBUF statbuf;
|
|
405
|
+ fmap_t *input;
|
|
406
|
+ int ret;
|
406
|
407
|
|
407
|
|
- hwp5_debug("HWP5.x: Sending %s for decompress and scan\n", name);
|
|
408
|
+ hwp5_debug("HWP5.x: Sending %s for decompress and scan\n", name);
|
408
|
409
|
|
409
|
|
- /* fmap the input file for easier manipulation */
|
410
|
|
- if (FSTAT(fd, &statbuf) == -1) {
|
411
|
|
- cli_errmsg("HWP5.x: Can't stat file descriptor\n");
|
412
|
|
- return CL_ESTAT;
|
413
|
|
- }
|
|
410
|
+ /* fmap the input file for easier manipulation */
|
|
411
|
+ if (FSTAT(fd, &statbuf) == -1) {
|
|
412
|
+ cli_errmsg("HWP5.x: Can't stat file descriptor\n");
|
|
413
|
+ return CL_ESTAT;
|
|
414
|
+ }
|
414
|
415
|
|
415
|
|
- input = fmap(fd, 0, statbuf.st_size);
|
416
|
|
- if (!input) {
|
417
|
|
- cli_errmsg("HWP5.x: Failed to get fmap for input stream\n");
|
418
|
|
- return CL_EMAP;
|
|
416
|
+ input = fmap(fd, 0, statbuf.st_size);
|
|
417
|
+ if (!input) {
|
|
418
|
+ cli_errmsg("HWP5.x: Failed to get fmap for input stream\n");
|
|
419
|
+ return CL_EMAP;
|
|
420
|
+ }
|
|
421
|
+ ret = decompress_and_callback(ctx, input, 0, 0, "HWP5.x", hwp5_cb, NULL);
|
|
422
|
+ funmap(input);
|
|
423
|
+ return ret;
|
419
|
424
|
}
|
420
|
|
- ret = decompress_and_callback(ctx, input, 0, 0, "HWP5.x", hwp5_cb, NULL);
|
421
|
|
- funmap(input);
|
422
|
|
- return ret;
|
423
|
425
|
}
|
424
|
|
- }
|
425
|
426
|
|
426
|
427
|
#if HAVE_JSON
|
427
|
|
- /* JSON Output Summary Information */
|
428
|
|
- if (ctx->options & CL_SCAN_FILE_PROPERTIES && ctx->properties != NULL) {
|
429
|
|
- if (name && !strncmp(name, "_5_hwpsummaryinformation", 24)) {
|
430
|
|
- cli_dbgmsg("HWP5.x: Detected a '_5_hwpsummaryinformation' stream\n");
|
431
|
|
- /* JSONOLE2 - what to do if something breaks? */
|
432
|
|
- if (cli_ole2_summary_json(ctx, fd, 2) == CL_ETIMEOUT)
|
433
|
|
- return CL_ETIMEOUT;
|
|
428
|
+ /* JSON Output Summary Information */
|
|
429
|
+ if (ctx->options & CL_SCAN_FILE_PROPERTIES && ctx->properties != NULL) {
|
|
430
|
+ if (name && !strncmp(name, "_5_hwpsummaryinformation", 24)) {
|
|
431
|
+ cli_dbgmsg("HWP5.x: Detected a '_5_hwpsummaryinformation' stream\n");
|
|
432
|
+ /* JSONOLE2 - what to do if something breaks? */
|
|
433
|
+ if (cli_ole2_summary_json(ctx, fd, 2) == CL_ETIMEOUT)
|
|
434
|
+ return CL_ETIMEOUT;
|
|
435
|
+ }
|
434
|
436
|
}
|
435
|
|
- }
|
436
|
437
|
|
437
|
438
|
#endif
|
|
439
|
+ }
|
438
|
440
|
|
439
|
441
|
/* normal streams */
|
440
|
442
|
return cli_magic_scandesc(fd, ctx);
|