LCOV - code coverage report
Current view: top level - src/server/protocol2 - bsigs.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 30 0.0 %
Date: 2016-07-02 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "../../burp.h"
       2             : #include "../../attribs.h"
       3             : #include "../../base64.h"
       4             : #include "../../fzp.h"
       5             : #include "../../handy.h"
       6             : #include "../../hexmap.h"
       7             : #include "../../iobuf.h"
       8             : #include "../../log.h"
       9             : #include "../../protocol2/blk.h"
      10             : 
      11             : static const char *path=NULL;
      12             : 
      13             : static int usage(void)
      14             : {
      15           0 :         printf("\nUsage: %s [filename]\n\n", prog);
      16             :         return 1;
      17             : }
      18             : 
      19           0 : static int parse_cmd(struct iobuf *rbuf, struct blk *blk, struct sbuf *sb)
      20             : {
      21           0 :         int ret=-1;
      22             : 
      23           0 :         printf("%c%04X", rbuf->cmd, (unsigned int)rbuf->len);
      24           0 :         switch(rbuf->cmd)
      25             :         {
      26             :                 case CMD_SIG:
      27           0 :                         if(blk_set_from_iobuf_sig_and_savepath(blk, rbuf))
      28             :                                 goto end;
      29             :                         printf("%016" PRIX64 "%s%s\n",
      30             :                                 blk->fingerprint,
      31             :                                 bytes_to_md5str(blk->md5sum),
      32           0 :                                 uint64_to_savepathstr_with_sig(blk->savepath));
      33             :                         break;
      34             :                 case CMD_FINGERPRINT:
      35           0 :                         if(blk_set_from_iobuf_fingerprint(blk, rbuf))
      36             :                                 goto end;
      37           0 :                         printf("%016" PRIX64 "\n", blk->fingerprint);
      38             :                         break;
      39             :                 case CMD_SAVE_PATH:
      40           0 :                         if(blk_set_from_iobuf_savepath(blk, rbuf))
      41             :                                 goto end;
      42           0 :                         printf("%s\n", uint64_to_savepathstr(blk->savepath));
      43             :                         break;
      44             :                 case CMD_DATA:
      45           0 :                         logp("\n%s looks like a data file\n", path);
      46             :                         goto end;
      47             : /*
      48             :         FIX THIS - give a flag to tell it to decode attributes.
      49             :                 case CMD_ATTRIBS:
      50             :                         memcpy(&sb->attr, rbuf, sizeof(struct iobuf));
      51             :                         attribs_decode(sb);
      52             :                         printf("compression: %d\n", sb->compression);
      53             :                         break;
      54             : */
      55             :                 default:
      56           0 :                         printf("%s\n", rbuf->buf);
      57             :                         break;
      58             :         }
      59             :         ret=0;
      60             : end:
      61           0 :         return ret;
      62             : }
      63             : 
      64           0 : int run_bsigs(int argc, char *argv[])
      65             : {
      66           0 :         int ret=1;
      67           0 :         fzp *fzp=NULL;
      68             :         struct iobuf rbuf;
      69             :         struct blk blk;
      70           0 :         struct sbuf *sb=sbuf_alloc(PROTO_1);
      71             :         memset(&rbuf, 0, sizeof(struct iobuf));
      72             : 
      73           0 :         base64_init();
      74             : 
      75           0 :         if(argc!=2)
      76           0 :                 return usage();
      77           0 :         path=argv[1];
      78             : 
      79           0 :         if(!(fzp=fzp_gzopen(path, "rb")))
      80             :                 goto end;
      81             :         while(1)
      82             :         {
      83           0 :                 iobuf_free_content(&rbuf);
      84           0 :                 switch(iobuf_fill_from_fzp(&rbuf, fzp))
      85             :                 {
      86           0 :                         case 1: ret=0; // Finished OK.
      87             :                         case -1: goto end; // Error.
      88             :                 }
      89             : 
      90           0 :                 if(parse_cmd(&rbuf, &blk, sb)) goto end;
      91             :         }
      92             : 
      93             : end:
      94           0 :         iobuf_free_content(&rbuf);
      95           0 :         fzp_close(&fzp);
      96           0 :         return ret;
      97             : }

Generated by: LCOV version 1.10