1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-27 02:18:21 +00:00

rule engine: prevent integer underflow and dead code

This commit is contained in:
philsmd 2017-02-15 12:41:32 +01:00
parent b4bfade4ec
commit fe33957303
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF

View File

@ -663,6 +663,7 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
break; break;
case 0: case 0:
if (rule_pos == 0) return -1;
return rule_pos - 1; return rule_pos - 1;
default: default:
@ -670,14 +671,9 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
} }
} }
if (rule_cnt > 0)
{
return rule_pos; return rule_pos;
} }
return -1;
}
bool kernel_rules_has_noop (const kernel_rule_t *kernel_rules_buf, const u32 kernel_rules_cnt) bool kernel_rules_has_noop (const kernel_rule_t *kernel_rules_buf, const u32 kernel_rules_cnt)
{ {
for (u32 kernel_rules_pos = 0; kernel_rules_pos < kernel_rules_cnt; kernel_rules_pos++) for (u32 kernel_rules_pos = 0; kernel_rules_pos < kernel_rules_cnt; kernel_rules_pos++)