Skip to content

Commit

Permalink
dynamic: check result of strstr in valid() to fix crash
Browse files Browse the repository at this point in the history
Related to openwall#5157
  • Loading branch information
AlekseyCherepanov committed Jul 2, 2022
1 parent 8c2b645 commit a298bfb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dynamic_fmt.c
Expand Up @@ -613,7 +613,9 @@ static int valid(char *ciphertext, struct fmt_main *pFmt)
return 0; // username is too long
} else {
/* salt and username */
char *t = strstr(&ciphertext[pPriv->dynamic_SALT_OFFSET], "$$U");;
char *t = strstr(&ciphertext[pPriv->dynamic_SALT_OFFSET], "$$U");
if (!t)
return 0; // no username
/* salt_external_to_internal_convert parses fields from right to left, but it may overwrite found fields */
if (strstr(t + 3, "$$U"))
return 0; // second $$U is prohibited (for simplicity)
Expand Down

0 comments on commit a298bfb

Please sign in to comment.