Skip to content

Commit

Permalink
#404 fix check_list return values
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Jan 22, 2018
1 parent 3d87e2d commit fd78549
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- heap-buffer-overflow in flow_decode (#407)
- Rewrite zero IP total length field to match the actual packet length (#406)
- stack-buffer-overflow in tcpcapinfo (#405)
- tcpprep --include option does not exclude (#404)

05/10/2017 Version 4.2.6
- Test fails on sparc64 (#393)
Expand Down
23 changes: 9 additions & 14 deletions src/common/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ parse_list(tcpr_list_t ** listdata, char *ourstr)

/**
* Checks to see if the given integer exists in the LIST.
* Return 1 if in the list, otherwise 0
*/
tcpr_dir_t
check_list(tcpr_list_t * list, COUNTER value)
Expand All @@ -157,28 +158,22 @@ check_list(tcpr_list_t * list, COUNTER value)
do {
if ((current->min != 0) && (current->max != 0)) {
if ((value >= current->min) && (value <= current->max))
return TCPR_DIR_C2S;
}
else if (current->min == 0) {
return 1;
} else if (current->min == 0) {
if (value <= current->max)
return TCPR_DIR_C2S;
}
else if (current->max == 0) {
return 1;
} else if (current->max == 0) {
if (value >= current->min)
return TCPR_DIR_C2S;
return 1;
}

if (current->next != NULL) {
if (current->next != NULL)
current = current->next;
}
else {
else
current = NULL;
}

} while (current != NULL);

return TCPR_DIR_S2C;

return 0;
}


Expand Down
2 changes: 2 additions & 0 deletions src/tcpprep.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,13 @@ process_raw_packets(pcap_t * pcap)
/* look for include or exclude LIST match */
if (options->xX.list != NULL) {
if (options->xX.mode < xXExclude) {
/* include list */
if (!check_list(options->xX.list, packetnum)) {
add_cache(&(options->cachedata), DONT_SEND, 0);
continue;
}
}
/* exclude list */
else if (check_list(options->xX.list, packetnum)) {
add_cache(&(options->cachedata), DONT_SEND, 0);
continue;
Expand Down

0 comments on commit fd78549

Please sign in to comment.