From 8e4e42a613e8d25a07254080e928c3df3c07adcc Mon Sep 17 00:00:00 2001 From: philsmd <921533+philsmd@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:46:50 +0100 Subject: [PATCH] prevent integer overflows in rp.c --- src/rp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rp.c b/src/rp.c index cef7c293d..64e197c71 100644 --- a/src/rp.c +++ b/src/rp.c @@ -770,6 +770,13 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 { rule_len = (u32) fgetl (&fp, rule_buf, HCBUFSIZ_LARGE); + if (rule_line >= 0xffffffff) + { + event_log_error (hashcat_ctx, "Unsupported number of lines in rule file %s", rp_file); + + return -1; + } + rule_line++; if (rule_len == 0) continue; @@ -807,6 +814,13 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 continue; } + if (kernel_rules_cnt >= 0xffffffff) + { + event_log_error (hashcat_ctx, "Unsupported number of rules in file %s", rp_file); + + return -1; + } + kernel_rules_cnt++; }