diff -urp john-1.7.4/src/rules.c john-1.7.4-mod/src/rules.c --- john-1.7.4/src/rules.c 2009-12-24 05:02:52 +0000 +++ john-1.7.4-mod/src/rules.c 2010-01-03 18:26:56 +0000 @@ -258,7 +258,7 @@ void rules_init(int max_length) rules_init_length(max_length); } -char *rules_reject(char *rule, int split, struct db_main *db) +char *rules_reject(char *rule, int split, char *last, struct db_main *db) { static char out_rule[RULE_BUFFER_SIZE]; @@ -309,7 +309,7 @@ char *rules_reject(char *rule, int split accept: rules_pass--; strnzcpy(out_rule, rule - 1, sizeof(out_rule)); - rules_apply("", out_rule, split, NULL); + rules_apply("", out_rule, split, last); rules_pass++; return out_rule; @@ -905,15 +905,13 @@ out_OK: if (length >= ARCH_SIZE - 1) { if (*(ARCH_WORD *)in != *(ARCH_WORD *)last) return in; - if (!strcmp(&in[ARCH_SIZE - 1], &last[ARCH_SIZE - 1])) - goto out_NULL; - return in; + if (strcmp(&in[ARCH_SIZE - 1], &last[ARCH_SIZE - 1])) + return in; + return NULL; } - if (last[2]) - return in; - if (in[0] != last[0]) + if (last[length]) return in; - if (in[1] != last[1] && length) + if (memcmp(in, last, length)) return in; return NULL; } @@ -967,7 +965,7 @@ int rules_check(struct rpp_context *star rules_pass = -1; /* rules_reject() will turn this into -2 */ while ((rule = rpp_next(&ctx))) { - rules_reject(rule, split, NULL); + rules_reject(rule, split, NULL, NULL); if (rules_errno) break; if (ctx.input) rules_line = ctx.input->number; diff -urp john-1.7.4/src/rules.h john-1.7.4-mod/src/rules.h --- john-1.7.4/src/rules.h 2009-12-24 02:38:12 +0000 +++ john-1.7.4-mod/src/rules.h 2009-12-28 19:28:21 +0000 @@ -54,8 +54,11 @@ extern void rules_init(int max_length); * * split == 0 "single crack" mode rules allowed * split < 0 "single crack" mode rules are invalid + * + * last may specify which internal buffer must not be touched. */ -extern char *rules_reject(char *rule, int split, struct db_main *db); +extern char *rules_reject(char *rule, int split, char *last, + struct db_main *db); /* * Applies rule to a word. Returns the updated word, or NULL if rejected or diff -urp john-1.7.4/src/single.c john-1.7.4-mod/src/single.c --- john-1.7.4/src/single.c 2009-12-24 00:41:54 +0000 +++ john-1.7.4-mod/src/single.c 2009-12-28 19:27:22 +0000 @@ -309,7 +309,7 @@ static void single_run(void) saved_min = rec_rule; while ((prerule = rpp_next(rule_ctx))) { - if (!(rule = rules_reject(prerule, 0, single_db))) { + if (!(rule = rules_reject(prerule, 0, NULL, single_db))) { log_event("- Rule #%d: '%.100s' rejected", ++rule_number, prerule); continue; diff -urp john-1.7.4/src/wordlist.c john-1.7.4-mod/src/wordlist.c --- john-1.7.4/src/wordlist.c 2009-12-24 00:42:27 +0000 +++ john-1.7.4-mod/src/wordlist.c 2009-12-28 19:28:07 +0000 @@ -194,7 +194,7 @@ void do_wordlist_crack(struct db_main *d if (prerule) do { if (rules) { - if ((rule = rules_reject(prerule, -1, db))) { + if ((rule = rules_reject(prerule, -1, last, db))) { if (strcmp(prerule, rule)) log_event("- Rule #%d: '%.100s'" " accepted as '%.100s'",