Skip to content

Commit

Permalink
Merge pull request appneta#386 from appneta/Bug_#385_issues_build-scan
Browse files Browse the repository at this point in the history
Bug appneta#384 fixes based on build-scan
  • Loading branch information
fklassen authored May 5, 2017
2 parents 0e9631f + ca8e891 commit e752775
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
05/02/2017 Version 4.2.5
- Fix issues found by build-scan (#384)
- Improve --portmap help message (#381)
- AFL detected security crash in fuzz feature (#380)
- Coverity static scan detected issues (#374)
Expand Down
1 change: 1 addition & 0 deletions src/common/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
lastcache = *cachedata;
}
else {
lastcache = *cachedata;
/* check to see if this is the last bit in this struct */
if ((lastcache->packets + 1) > (CACHEDATASIZE * CACHE_PACKETS_PER_BYTE)) {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/common/cidr.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ cidr2cidr(char *cidr)
if (p) {
*p = 0;
++p;
count = sscanf(p, "%d", &newcidr->masklen);
sscanf(p, "%d", &newcidr->masklen);
} else {
newcidr->masklen = 128;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ parse_services(const char *file, tcpr_services_t *services)
FILE *service = NULL;
char service_line[MAXLINE], port[10], proto[10];
regex_t preg;
uint16_t portc;
size_t nmatch = 3;
regmatch_t pmatch[3];
static const char regex[] = "([0-9]+)/(tcp|udp)"; /* matches the port as pmatch[1], service pmatch[2] */
Expand Down Expand Up @@ -66,12 +65,13 @@ parse_services(const char *file, tcpr_services_t *services)
/* zero out our vars */
memset(port, '\0', 10);
memset(proto, '\0', 10);
portc = 0;

dbgx(4, "Processing: %s", service_line);

/* look for format of 1234/tcp */
if ((regexec(&preg, service_line, nmatch, pmatch, 0)) == 0) { /* matches */
uint16_t portc;

if (nmatch < 2) {
err(-1, "WTF? I matched the line, but I don't know where!");
}
Expand Down
4 changes: 2 additions & 2 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,12 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
int cache_file_idx;
struct pcap_pkthdr pkthdr1, pkthdr2;
u_char *pktdata1 = NULL, *pktdata2 = NULL, *pktdata = NULL;
sendpacket_t *sp = ctx->intf1;
sendpacket_t *sp;
COUNTER pktlen;
packet_cache_t *cached_packet1 = NULL, *cached_packet2 = NULL;
packet_cache_t **prev_packet1 = NULL, **prev_packet2 = NULL;
struct pcap_pkthdr *pkthdr_ptr;
int datalink = options->file_cache[cache_file_idx1].dlt;
int datalink;
COUNTER start_us;
COUNTER end_us;
COUNTER skip_length = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/tcpedit/plugins/dlt_en10mb/en10mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ dlt_en10mb_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
assert(ctx);
assert(packet);


l2len = -1;
eth = (struct tcpr_ethernet_hdr *)packet;
switch (ntohs(eth->ether_type)) {
case ETHERTYPE_VLAN:
Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/portmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ports2PORT(char *ports)
* to do it once now, rather then each time we have to do a lookup
*/
portmap_head = new_portmap();
portmap = portmap_head;
portmap = portmap_last = portmap_head;

/* process a range, setting from_begin & from_end */
if (strchr(from_s, '-')) {
Expand Down
6 changes: 1 addition & 5 deletions src/tcpprep.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,14 @@ main(int argc, char *argv[])
int out_file;
COUNTER totpackets = 0;
char errbuf[PCAP_ERRBUF_SIZE];
int optct = 0;
tcpprep_opt_t *options;

tcpprep = tcpprep_init();
options = tcpprep->options;

optct = optionProcess(&tcpprepOptions, argc, argv);
optionProcess(&tcpprepOptions, argc, argv);
tcpprep_post_args(tcpprep, argc, argv);

argc -= optct;
argv += optct;

/* open the cache file */
if ((out_file = open(OPT_ARG(CACHEFILE), O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH)) == -1)
Expand Down

0 comments on commit e752775

Please sign in to comment.