From 8aac1ccc52ae0fd53addce6f2acbda2c6c2e638a Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sat, 17 Aug 2013 10:20:17 -0500 Subject: [PATCH 1/3] Make oom check consistent, check and correct overlong payload size --- src/probe_modules/module_udp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/probe_modules/module_udp.c b/src/probe_modules/module_udp.c index aaa6151..1f3be62 100644 --- a/src/probe_modules/module_udp.c +++ b/src/probe_modules/module_udp.c @@ -50,6 +50,8 @@ int udp_global_initialize(struct state_conf * zconf) { return(0); args = strdup(zconf->probe_args); + if (! args) exit(1) + c = strchr(args, ':'); if (! c) { fprintf(stderr, "error: unknown UDP probe specification (expected file:/path, text:STRING, or hex:01020304)\n"); @@ -96,6 +98,11 @@ int udp_global_initialize(struct state_conf * zconf) { exit(1); } + if (udp_send_msg_len > 1472) { + fprintf(stderr, "warning: reducing UDP payload to 1472 bytes (from %d) to fit on the wire\n", udp_send_msg_len); + udp_send_msg_len = 1472; + } + free(args); return(0); } From ed47f926f5454aede508dccc89b25e524c2a5b07 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sat, 17 Aug 2013 14:06:34 -0500 Subject: [PATCH 2/3] Free memory on close --- src/probe_modules/module_udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe_modules/module_udp.c b/src/probe_modules/module_udp.c index 1f3be62..024cd70 100644 --- a/src/probe_modules/module_udp.c +++ b/src/probe_modules/module_udp.c @@ -304,7 +304,7 @@ probe_module_t module_udp = { .print_packet = &udp_print_packet, .validate_packet = &udp_validate_packet, .classify_packet = &udp_classify_packet, - .close = NULL, + .close = udp_global_cleanup, .responses = responses }; From 15036cfe8312f7abc5a8353455805550817236c8 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sat, 17 Aug 2013 14:11:58 -0500 Subject: [PATCH 3/3] Proper cleanup and typo fixes --- src/probe_modules/module_udp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/probe_modules/module_udp.c b/src/probe_modules/module_udp.c index 024cd70..ce83c93 100644 --- a/src/probe_modules/module_udp.c +++ b/src/probe_modules/module_udp.c @@ -50,7 +50,7 @@ int udp_global_initialize(struct state_conf * zconf) { return(0); args = strdup(zconf->probe_args); - if (! args) exit(1) + if (! args) exit(1); c = strchr(args, ':'); if (! c) { @@ -107,8 +107,13 @@ int udp_global_initialize(struct state_conf * zconf) { return(0); } -int udp_global_cleanup(void) { +int udp_cleanup(struct state_conf *zconf, struct state_send *send_state, struct state_recv *recv_state) { + assert(zconf); + assert(send_state); + assert(recv_state); + if (udp_send_msg) free(udp_send_msg); + udp_send_msg = NULL; return(0); } @@ -304,7 +309,7 @@ probe_module_t module_udp = { .print_packet = &udp_print_packet, .validate_packet = &udp_validate_packet, .classify_packet = &udp_classify_packet, - .close = udp_global_cleanup, + .close = &udp_cleanup, .responses = responses };