Browse code

cid 12154 - fix error state for reading LZMA compressed flash

Kevin Lin authored on 2015/08/18 07:04:39
Showing 1 changed files
... ...
@@ -185,8 +185,17 @@ static int scanzws(cli_ctx *ctx, struct swf_file_hdr *hdr)
185 185
         free(tmpname);
186 186
         return CL_EUNPACK;
187 187
     }
188
-    if (!ret)
189
-        return CL_EFORMAT; /* likely truncated */
188
+    /* nothing written, likely truncated */
189
+    if (!ret) {
190
+        cli_errmsg("scanzws: possibly truncated file\n");
191
+        close(fd);
192
+        if (cli_unlink(tmpname)) {
193
+            free(tmpname);
194
+            return CL_EUNLINK;
195
+        }
196
+        free(tmpname);
197
+        return CL_EFORMAT;
198
+    }
190 199
     offset += ret;
191 200
 
192 201
     memset(&lz, 0, sizeof(lz));