Browse code

hwp: change scan behavior on limits exceeded

Kevin Lin authored on 2016/02/02 03:22:59
Showing 1 changed files
... ...
@@ -139,7 +139,7 @@ static int decompress_and_callback(cli_ctx *ctx, fmap_t *input, off_t at, size_t
139 139
         zret = inflate(&zstrm, Z_SYNC_FLUSH);
140 140
         count = FILEBUFF - zstrm.avail_out;
141 141
         if (count) {
142
-            if (cli_checklimits("HWP", ctx, outsize + count, 0, 0) != CL_SUCCESS)
142
+            if ((ret = cli_checklimits("HWP", ctx, outsize + count, 0, 0)) != CL_SUCCESS)
143 143
                 break;
144 144
 
145 145
             if (cli_writen(ofd, outbuf, count) != count) {
... ...
@@ -163,13 +163,17 @@ static int decompress_and_callback(cli_ctx *ctx, fmap_t *input, off_t at, size_t
163 163
 
164 164
         cli_infomsg(ctx, "%s: Error decompressing stream. Scanning what was decompressed.\n", parent);
165 165
     }
166
-    if (len && remain > 0)
167
-        cli_infomsg(ctx, "%s: Error decompressing stream. Not all requested input was converted\n", parent);
168 166
 
169
-    cli_dbgmsg("%s: Decompressed %llu bytes to %s\n", parent, (long long unsigned)outsize, tmpname);
167
+    /* check for limits exceeded */
168
+    if (ret == CL_SUCCESS) {
169
+        if (len && remain > 0)
170
+            cli_infomsg(ctx, "%s: Error decompressing stream. Not all requested input was converted\n", parent);
170 171
 
171
-    /* scanning inflated stream */
172
-    ret = cb(cbdata, ofd, ctx);
172
+        cli_dbgmsg("%s: Decompressed %llu bytes to %s\n", parent, (long long unsigned)outsize, tmpname);
173
+
174
+        /* scanning inflated stream */
175
+        ret = cb(cbdata, ofd, ctx);
176
+    }
173 177
 
174 178
     /* clean-up */
175 179
  dc_end: