LCOV - code coverage report
Current view: top level - src/server/protocol1 - zlibio.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 14 27 51.9 %
Date: 2016-09-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             : #include "zlibio.h"
       7             : 
       8           4 : int zlib_inflate(struct asfd *asfd, const char *source_path,
       9             :         const char *dest_path, struct cntr *cntr)
      10             : {
      11           4 :         int ret=-1;
      12           4 :         size_t b=0;
      13             :         uint8_t in[ZCHUNK];
      14           4 :         struct fzp *src=NULL;
      15           4 :         struct fzp *dst=NULL;
      16             : 
      17           4 :         if(!(src=fzp_gzopen(source_path, "rb")))
      18             :         {
      19           0 :                 logw(asfd, cntr, "could not gzopen %s in %s: %s\n",
      20           0 :                         source_path, __func__, strerror(errno));
      21           0 :                 goto end;
      22             :         }
      23           4 :         if(!(dst=fzp_open(dest_path, "wb")))
      24             :         {
      25           0 :                 logw(asfd, cntr, "could not open %s in %s: %s\n",
      26           0 :                         dest_path, __func__, strerror(errno));
      27           0 :                 goto end;
      28             :         }
      29             : 
      30           8 :         while((b=fzp_read(src, in, ZCHUNK))>0)
      31             :         {
      32           4 :                 if(fzp_write(dst, in, b)!=b)
      33             :                 {
      34           0 :                         logw(asfd, cntr,
      35             :                                 "error when writing to %s\n", dest_path);
      36           0 :                         goto end;
      37             :                 }
      38             :         }
      39           4 :         if(!fzp_eof(src))
      40             :         {
      41           0 :                 logw(asfd, cntr,
      42             :                         "error while reading %s in %s\n",
      43             :                                 source_path, __func__);
      44           0 :                 goto end;
      45             :         }
      46           4 :         if(fzp_close(&dst))
      47             :         {
      48           0 :                 logw(asfd, cntr,
      49             :                         "error when closing %s in %s: %s\n",
      50           0 :                                 dest_path, __func__, strerror(errno));
      51           0 :                 goto end;
      52             :         }
      53             :         ret=0;
      54             : end:
      55           4 :         fzp_close(&src);
      56           4 :         fzp_close(&dst);
      57           4 :         return ret;
      58             : }

Generated by: LCOV version 1.10