Skip to content

Commit 4f29349

Browse files
committed
Format selection: Add an "after" option
Matches all formats after a specific one. Put in other words, skip all formats up to and including the named one. This is for situations where you test all formats and it segfaults on eg. foo-opencl. You can now resume the tests from the next format, using --format=/foo-opencl.
1 parent 75c7cd4 commit 4f29349

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

src/formats.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,27 @@ static int exclude_formats(char *rej_format, struct fmt_main **full_fmt_list)
235235
return removed;
236236
}
237237

238+
/* Exclusions. Drop all format(s) up to and including the matching rej_format from full list */
239+
static int exclude_formats_up_to(char *rej_format, struct fmt_main **full_fmt_list)
240+
{
241+
static int drop = 1;
242+
struct fmt_main *current;
243+
int removed = 0;
244+
245+
if ((current = *full_fmt_list))
246+
do {
247+
if (drop) {
248+
if (fmt_match(rej_format, current, 1))
249+
drop = 0;
250+
*full_fmt_list = current->next;
251+
removed++;
252+
} else
253+
break;
254+
} while ((current = current->next));
255+
256+
return removed;
257+
}
258+
238259
/* Inclusions. Move any format(s) matching req_format from full list to new list */
239260
static int include_formats(char *req_format, struct fmt_main **full_fmt_list)
240261
{
@@ -329,7 +350,7 @@ static void comma_split(struct list_main *dst, const char *src)
329350

330351
char* fmt_type(char *name)
331352
{
332-
if (name[1] && (name[0] == '+' || name[0] == '-'))
353+
if (name[1] && (name[0] == '+' || name[0] == '-' || name[0] == '/'))
333354
name++;
334355

335356
if (fmt_is_class(name))
@@ -357,9 +378,16 @@ int fmt_check_custom_list(void)
357378
fmt_list = NULL;
358379
fmt_tail = &fmt_list;
359380

360-
/* "-" Exclusions first, from the full list. */
381+
/* "-" or "/" Exclusions first, from the full list. */
361382
do {
362-
if (req_format->data[0] == '-') {
383+
if (req_format->data[0] == '/') {
384+
char *exclude_fmt = &(req_format->data[1]);
385+
386+
if (!exclude_fmt[0])
387+
error_msg("Error: '%s' in format list doesn't make sense\n", req_format->data);
388+
num_e += exclude_formats_up_to(exclude_fmt, &full_fmt_list);
389+
}
390+
else if (req_format->data[0] == '-') {
363391
char *exclude_fmt = &(req_format->data[1]);
364392

365393
if (!exclude_fmt[0])
@@ -371,7 +399,7 @@ int fmt_check_custom_list(void)
371399
/* Inclusions. Move to the new list. */
372400
req_format = req_formats->head;
373401
do {
374-
if ((req_format->data[0] != '-') && (req_format->data[0] != '+')) {
402+
if ((req_format->data[0] != '-') && (req_format->data[0] != '+') && (req_format->data[0] != '/')) {
375403
had_i = 1;
376404
if (!include_formats(req_format->data, &full_fmt_list) && !is_in_fmt_list(req_format->data)) {
377405
if (john_main_process)

src/john.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ static int exit_status = 0;
202202
static void john_register_one(struct fmt_main *format)
203203
{
204204
if (options.format) {
205-
if (options.format[0] == '-' && options.format[1]) {
205+
if (options.format[0] == '/' && options.format[1]) {
206+
static int drop = 1;
207+
208+
if (drop) {
209+
if (fmt_match(&options.format[1], format, 1))
210+
drop = 0;
211+
return;
212+
}
213+
} else if (options.format[0] == '-' && options.format[1]) {
206214
if (fmt_match(&options.format[1], format, 1))
207215
return;
208216
} else if (options.format[0] == '+' && options.format[1]) {

0 commit comments

Comments
 (0)