Browse code

pdfdecode: lzw dconf

Kevin Lin authored on 2016/04/15 04:17:02
Showing 3 changed files
... ...
@@ -130,6 +130,7 @@ static struct dconf_module modules[] = {
130 130
     { "OTHER",      "PREFILTERING", OTHER_CONF_PREFILTERING,1 },
131 131
     { "OTHER",      "PDFNAMEOBJ",   OTHER_CONF_PDFNAMEOBJ,  1 },
132 132
     { "OTHER",      "PRTNINTXN",   OTHER_CONF_PRTNINTXN,  1 },
133
+    { "OTHER",      "LZW",      OTHER_CONF_LZW,     1 },
133 134
 
134 135
     { "PHISHING",   "ENGINE",       PHISHING_CONF_ENGINE,   1 },
135 136
     { "PHISHING",   "ENTCONV",      PHISHING_CONF_ENTCONV,  1 },
... ...
@@ -121,6 +121,7 @@ struct cli_dconf {
121 121
 #define OTHER_CONF_PREFILTERING 0x80
122 122
 #define OTHER_CONF_PDFNAMEOBJ	0x100
123 123
 #define OTHER_CONF_PRTNINTXN	0x200
124
+#define OTHER_CONF_LZW		0x400
124 125
 
125 126
 /* Phishing flags */
126 127
 #define PHISHING_CONF_ENGINE   0x1
... ...
@@ -211,8 +211,21 @@ static int pdf_decodestream_internal(struct pdf_struct *pdf, struct pdf_obj *obj
211 211
         }
212 212
 
213 213
         if (rc != CL_SUCCESS) {
214
-            cli_dbgmsg("cli_pdf: error decoding, breaking after %d (of %lu) filters\n",
215
-                       i, (long unsigned)(obj->numfilters));
214
+            const char *reason;
215
+            switch (rc) {
216
+            case CL_VIRUS:
217
+                reason = "detection";
218
+                break;
219
+            case CL_BREAK:
220
+                reason = "break decoding";
221
+                break;
222
+            default:
223
+                reason = "error decoding";
224
+                break;
225
+            }
226
+
227
+            cli_dbgmsg("cli_pdf: %s, stopping after %d (of %lu) filters\n",
228
+                       reason, i, (long unsigned)(obj->numfilters));
216 229
             break;
217 230
         }
218 231
 
... ...
@@ -726,6 +739,9 @@ static int filter_lzwdecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct
726 726
     lzw_stream stream;
727 727
     int echg = 1, lzwstat, skip = 0, rc = CL_SUCCESS;
728 728
 
729
+    if (pdf->ctx && !(pdf->ctx->dconf->other & OTHER_CONF_LZW))
730
+        return CL_BREAK;
731
+
729 732
     if (params) {
730 733
         struct pdf_dict_node *node = params->nodes;
731 734