LCOV - code coverage report
Current view: top level - src - incexc_send.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 50 0.0 %
Date: 2016-02-29 Functions: 0 10 0.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "alloc.h"
       3             : #include "asfd.h"
       4             : #include "cmd.h"
       5             : #include "log.h"
       6             : #include "prepend.h"
       7             : #include "strlist.h"
       8             : 
       9           0 : static int send_incexc_string(struct asfd *asfd,
      10             :         const char *field, const char *str)
      11             : {
      12           0 :         char *tosend=NULL;
      13           0 :         int ret=-1;
      14           0 :         if(!str) return 0;
      15           0 :         if(!(tosend=prepend_n(field, str, strlen(str), " = ")))
      16             :                 goto end;
      17           0 :         if(asfd->write_str(asfd, CMD_GEN, tosend))
      18             :         {
      19           0 :                 logp("Error in async_write_str when sending incexc\n");
      20           0 :                 goto end;
      21             :         }
      22             :         ret=0;
      23             : end:
      24           0 :         free_w(&tosend);
      25           0 :         return ret;
      26             : }
      27             : 
      28           0 : static int send_incexc_str(struct asfd *asfd, struct conf *conf)
      29             : {
      30           0 :         return send_incexc_string(asfd, conf->field, get_string(conf));
      31             : }
      32             : 
      33           0 : static int send_incexc_uint(struct asfd *asfd, struct conf *conf)
      34             : {
      35           0 :         char tmp[64]="";
      36           0 :         snprintf(tmp, sizeof(tmp), "%d", get_int(conf));
      37           0 :         return send_incexc_string(asfd, conf->field, tmp);
      38             : }
      39             : 
      40           0 : static int send_incexc_uint64(struct asfd *asfd, struct conf *conf)
      41             : {
      42           0 :         char tmp[32]="";
      43           0 :         snprintf(tmp, sizeof(tmp), "%"PRIu64, get_uint64_t(conf));
      44           0 :         return send_incexc_string(asfd, conf->field, tmp);
      45             : }
      46             : 
      47           0 : static int send_incexc_strlist(struct asfd *asfd, struct conf *conf)
      48             : {
      49             :         struct strlist *l;
      50           0 :         for(l=get_strlist(conf); l; l=l->next)
      51           0 :                 if(send_incexc_string(asfd, conf->field, l->path)) return -1;
      52             :         return 0;
      53             : }
      54             : 
      55           0 : static int do_sends(struct asfd *asfd, struct conf **confs, int flag)
      56             : {
      57           0 :         int i=0;
      58           0 :         int r=-1;
      59           0 :         for(i=0; i<OPT_MAX; i++)
      60             :         {
      61           0 :                 if(!(confs[i]->flags & flag)) continue;
      62           0 :                 switch(confs[i]->conf_type)
      63             :                 {
      64             :                         case CT_STRING:
      65           0 :                                 if(send_incexc_str(asfd, confs[i]))
      66             :                                         goto end;
      67             :                                 break;
      68             :                         case CT_STRLIST:
      69           0 :                                 if(send_incexc_strlist(asfd, confs[i]))
      70             :                                         goto end;
      71             :                                 break;
      72             :                         case CT_UINT:
      73           0 :                                 if(send_incexc_uint(asfd, confs[i]))
      74             :                                         goto end;
      75             :                                 break;
      76             :                         case CT_SSIZE_T:
      77           0 :                                 if(send_incexc_uint64(asfd, confs[i]))
      78             :                                         goto end;
      79             :                                 break;
      80             :                         case CT_FLOAT:
      81             :                         case CT_MODE_T:
      82             :                         case CT_E_BURP_MODE:
      83             :                         case CT_E_PROTOCOL:
      84             :                         case CT_E_RECOVERY_METHOD:
      85             :                         case CT_E_RSHASH:
      86             :                         case CT_CNTR:
      87             :                                 break;
      88             :                 }
      89             :         }
      90             :         r=0;
      91             : end:
      92           0 :         return r;
      93             : }
      94             : 
      95           0 : static int do_request_response(struct asfd *asfd,
      96             :         const char *reqstr, const char *repstr)
      97             : {
      98           0 :         return (asfd->write_str(asfd, CMD_GEN, reqstr)
      99           0 :           || asfd_read_expect(asfd, CMD_GEN, repstr));
     100             : }
     101             : 
     102           0 : int incexc_send_client(struct asfd *asfd, struct conf **confs)
     103             : {
     104           0 :         if(do_request_response(asfd, "incexc", "incexc ok")
     105           0 :           || do_sends(asfd, confs, CONF_FLAG_INCEXC)
     106           0 :           || do_request_response(asfd, "incexc end", "incexc end ok"))
     107             :                 return -1;
     108           0 :         return 0;
     109             : }
     110             : 
     111           0 : int incexc_send_server(struct asfd *asfd, struct conf **confs)
     112             : {
     113             :         /* 'sincexc' and 'sincexc ok' have already been exchanged,
     114             :            so go straight into doing the sends. */
     115           0 :         if(do_sends(asfd, confs, CONF_FLAG_INCEXC)
     116           0 :           || do_request_response(asfd, "sincexc end", "sincexc end ok"))
     117             :                 return -1;
     118           0 :         return 0;
     119             : }
     120             : 
     121           0 : int incexc_send_server_restore(struct asfd *asfd, struct conf **confs)
     122             : {
     123             :         /* 'srestore' and 'srestore ok' have already been exchanged,
     124             :            so go straight into doing the sends. */
     125           0 :         if(do_sends(asfd, confs, CONF_FLAG_INCEXC_RESTORE)
     126           0 :           || do_request_response(asfd, "srestore end", "srestore end ok"))
     127             :                 return -1;
     128           0 :         return 0;
     129             : }

Generated by: LCOV version 1.10