Browse code

bb#11072: In case of SWF decompression error, scan data if any data was decompressed.

Shawn Webb authored on 2014/08/20 02:16:42
Showing 1 changed files
... ...
@@ -206,14 +206,21 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr)
206 206
     } while(zret == Z_OK);
207 207
 
208 208
     if((zret != Z_STREAM_END && zret != Z_OK) || (zret = inflateEnd(&stream)) != Z_OK) {
209
-	cli_infomsg(ctx, "scancws: Error decompressing SWF file\n");
210
-	close(fd);
211
-	if(cli_unlink(tmpname)) {
212
-	    free(tmpname);
213
-	    return CL_EUNLINK;
214
-	}
215
-	free(tmpname);
216
-	return CL_EUNPACK;
209
+        /*
210
+         * outsize is initialized to 8, it being 8 here means that we couldn't even read a single byte.
211
+         * If outsize > 8, then we have data. Let's scan what we have.
212
+         */
213
+        if (outsize == 8) {
214
+            cli_infomsg(ctx, "scancws: Error decompressing SWF file. No data decompressed.\n");
215
+            close(fd);
216
+            if(cli_unlink(tmpname)) {
217
+                free(tmpname);
218
+                return CL_EUNLINK;
219
+            }
220
+            free(tmpname);
221
+            return CL_EUNPACK;
222
+        }
223
+        cli_infomsg(ctx, "scancws: Error decompressing SWF file. Scanning what was decompressed.\n");
217 224
     }
218 225
     cli_dbgmsg("SWF: Decompressed to %s, size %d\n", tmpname, outsize);
219 226