LCOV - code coverage report
Current view: top level - src/server/protocol1 - zlibio.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 15 25 60.0 %
Date: 2015-11-30 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "../../burp.h"
       2             : #include "../../asfd.h"
       3             : #include "../../async.h"
       4             : #include "../../fzp.h"
       5             : #include "../../log.h"
       6             : 
       7           4 : int zlib_inflate(struct asfd *asfd, const char *source_path,
       8             :         const char *dest_path, struct cntr *cntr)
       9             : {
      10           4 :         int ret=-1;
      11           4 :         size_t b=0;
      12             :         uint8_t in[ZCHUNK];
      13           4 :         struct fzp *src=NULL;
      14           4 :         struct fzp *dst=NULL;
      15             : 
      16           4 :         if(!(src=fzp_gzopen(source_path, "rb")))
      17             :         {
      18             :                 logw(asfd, cntr, "could not gzopen %s in %s: %s\n",
      19           0 :                         source_path, __func__, strerror(errno));
      20           0 :                 goto end;
      21             :         }
      22           4 :         if(!(dst=fzp_open(dest_path, "wb")))
      23             :         {
      24             :                 logw(asfd, cntr, "could not open %s in %s: %s\n",
      25           0 :                         dest_path, __func__, strerror(errno));
      26           0 :                 goto end;
      27             :         }
      28             : 
      29          12 :         while((b=fzp_read(src, in, ZCHUNK))>0)
      30             :         {
      31           4 :                 if(fzp_write(dst, in, b)!=b)
      32             :                 {
      33             :                         logw(asfd, cntr,
      34           0 :                                 "error when writing to %s\n", dest_path);
      35           0 :                         goto end;
      36             :                 }
      37             :         }
      38           4 :         if(!fzp_eof(src))
      39             :         {
      40             :                 logw(asfd, cntr,
      41             :                         "error while reading %s in %s\n",
      42           0 :                                 source_path, __func__);
      43           0 :                 goto end;
      44             :         }
      45           4 :         if(fzp_close(&dst))
      46             :         {
      47             :                 logw(asfd, cntr,
      48             :                         "error when closing %s in %s: %s\n",
      49           0 :                                 dest_path, __func__, strerror(errno));
      50           0 :                 goto end;
      51             :         }
      52           4 :         ret=0;
      53             : end:
      54           4 :         fzp_close(&src);
      55           4 :         fzp_close(&dst);
      56           4 :         return ret;
      57             : }

Generated by: LCOV version 1.10