commit 975b62817ab1a0c47dbf173b799763bd5c3787d3
parent 2633d4d5b0aa0fb58add270b6ded57904b8de6b1
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date: Thu, 17 Sep 2020 11:20:08 +1000
replace stop i32 with length check conditional
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/ngrep.c b/ngrep.c
@@ -916,10 +916,9 @@ re_match_func(uint8_t *data, uint32_t len, size_t *mindex, size_t *msize)
bool
bin_match_func(uint8_t *data, uint32_t len, size_t *mindex, size_t *msize)
{
- int32_t stop = len - match_len;
uint8_t *p;
- if (stop < 0)
+ if (match_len > len)
return false;
if ((p = memmem(data, len, bin_data, match_len)) != NULL) {
@@ -1309,7 +1308,7 @@ clean_exit(int sig)
* user to see counts not match what ngrep thinks.
*/
if (quiet < 1 && sig >= 0 && read_file == NULL)
- printf("%u received, %u matched\n", seen_frames, matches);
+ printf("%zu received, %zu matched\n", seen_frames, matches);
if (pd)
pcap_close(pd);