Browse code

msxml_parser: add custom callback data slot

Kevin Lin authored on 2016/05/24 05:08:05
Showing 3 changed files
... ...
@@ -1933,11 +1933,13 @@ static int hwpml_scan_cb(void *cbdata, int fd, cli_ctx *ctx)
1933 1933
     return cli_magic_scandesc(fd, ctx);
1934 1934
 }
1935 1935
 
1936
-static int hwpml_binary_cb(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs)
1936
+static int hwpml_binary_cb(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs, void *cbdata)
1937 1937
 {
1938 1938
     int i, ret, df = 0, com = 0, enc = 0;
1939 1939
     char *tempfile;
1940 1940
 
1941
+    UNUSEDPARAM(cbdata);
1942
+
1941 1943
     /* check attributes for compression and encoding */
1942 1944
     for (i = 0; i < num_attribs; i++) {
1943 1945
         if (!strcmp(attribs[i].key, "Compress")) {
... ...
@@ -421,7 +421,7 @@ static int msxml_parse_element(struct msxml_ctx *mxctx, xmlTextReaderPtr reader,
421 421
 
422 422
                     cli_dbgmsg("msxml_parse_element: extracted binary data to %s\n", tempfile);
423 423
 
424
-                    ret = mxctx->scan_cb(of, ctx, num_attribs, attribs);
424
+                    ret = mxctx->scan_cb(of, ctx, num_attribs, attribs, mxctx->scan_data);
425 425
                     if (!(ctx->engine->keeptmp))
426 426
                         cli_unlink(tempfile);
427 427
                     free(tempfile);
... ...
@@ -489,9 +489,9 @@ static int msxml_parse_element(struct msxml_ctx *mxctx, xmlTextReaderPtr reader,
489 489
                 /* callback-based scanning mechanism for comments (used by MHTML) */
490 490
                 if ((keyinfo->type & MSXML_COMMENT_CB) && mxctx->comment_cb) {
491 491
 #if HAVE_JSON
492
-                    ret = mxctx->comment_cb((const char *)node_value, ctx, thisjobj);
492
+                    ret = mxctx->comment_cb((const char *)node_value, ctx, thisjobj, mxctx->comment_data);
493 493
 #else
494
-                    ret = mxctx->comment_cb((const char *)node_value, ctx, NULL);
494
+                    ret = mxctx->comment_cb((const char *)node_value, ctx, NULL, mxctx->comment_data);
495 495
 #endif
496 496
                     if (ret != CL_SUCCESS && (ret != CL_VIRUS || (!SCAN_ALL && ret == CL_VIRUS))) {
497 497
                         return ret;
... ...
@@ -76,12 +76,14 @@ struct key_entry {
76 76
     uint32_t type;
77 77
 };
78 78
 
79
-typedef int (*msxml_scan_cb)(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs);
80
-typedef int (*msxml_comment_cb)(const char *comment, cli_ctx *ctx, void *wrkjobj);
79
+typedef int (*msxml_scan_cb)(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs, void *cbdata);
80
+typedef int (*msxml_comment_cb)(const char *comment, cli_ctx *ctx, void *wrkjobj, void *cbdata);
81 81
 
82 82
 struct msxml_ctx {
83 83
     msxml_scan_cb scan_cb;
84
+    void *scan_data;
84 85
     msxml_comment_cb comment_cb;
86
+    void *comment_data;
85 87
     struct msxml_ictx *ictx;
86 88
 };
87 89