Skip to content

Commit 18d8c49

Browse files
committed
Rules: Move RULE_WORD_SIZE from params.h to rules.c
1 parent 5da7745 commit 18d8c49

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/params.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,6 @@ extern unsigned int password_hash_thresholds[PASSWORD_HASH_SIZES];
427427
*/
428428
#define RULE_RANGES_MAX 30
429429

430-
/*
431-
* Buffer size for words while applying rules, should be at least as large
432-
* as PLAINTEXT_BUFFER_SIZE.
433-
*/
434-
#define RULE_WORD_SIZE 320
435-
436430
/*
437431
* By default we mute some rules logging in pipe mode, if number of rules
438432
* (after PP and dupe rule suppression) is larger than this threshold.

src/rules.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
#include "mask.h"
2525
#include "encoding_data.h"
2626

27+
/*
28+
* Buffer size for words while applying rules, should be at least as large
29+
* as PLAINTEXT_BUFFER_SIZE, but not large enough that fitting strings could
30+
* reach or exceed INFINITE_LENGTH or INVALID_LENGTH defined further below.
31+
*/
32+
#define RULE_WORD_SIZE PLAINTEXT_BUFFER_SIZE
33+
2734
/*
2835
* Error codes.
2936
*/

src/single.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ static int single_process_pw(struct db_salt *salt, struct db_password *pw,
654654
struct list_entry *global_head = single_seed->head;
655655
int first_global, second_global;
656656
int first_number, second_number;
657-
char pair[RULE_WORD_SIZE];
657+
char pair[PLAINTEXT_BUFFER_SIZE];
658658
int split;
659659
char *key;
660660

@@ -689,8 +689,8 @@ static int single_process_pw(struct db_salt *salt, struct db_password *pw,
689689
if (first == second || (first_global && second_global))
690690
continue;
691691
if ((split = strlen(first->data)) < length) {
692-
strnzcpy(pair, first->data, RULE_WORD_SIZE);
693-
strnzcat(pair, second->data, RULE_WORD_SIZE);
692+
strnzcpy(pair, first->data, PLAINTEXT_BUFFER_SIZE);
693+
strnzcat(pair, second->data, PLAINTEXT_BUFFER_SIZE);
694694

695695
if ((key = rules_apply(pair, rule, split)))
696696
if (ext_filter(key))
@@ -705,7 +705,7 @@ static int single_process_pw(struct db_salt *salt, struct db_password *pw,
705705
if (!first_global && first->data[1]) {
706706
pair[0] = first->data[0];
707707
pair[1] = 0;
708-
strnzcat(pair, second->data, RULE_WORD_SIZE);
708+
strnzcat(pair, second->data, PLAINTEXT_BUFFER_SIZE);
709709

710710
if ((key = rules_apply(pair, rule, 1)))
711711
if (ext_filter(key))

0 commit comments

Comments
 (0)