Skip to content

Commit

Permalink
dynamic: harden valid() to fix buffer overflow in dynamic_1552
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 a298bfb commit 0de329a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dynamic_fmt.c
Expand Up @@ -566,7 +566,8 @@ static int valid(char *ciphertext, struct fmt_main *pFmt)
if (cp[cipherTextLen] && cp[cipherTextLen] != '$')
return 0;
// NOTE if looking at this in the future, this was not my fix.
if (strlen(&cp[cipherTextLen]) > SALT_SIZE)
// dynamic_1552: $s1$$Uuser --> 6+len(s1)+1+len(user) <= SALT_SIZE
if (strlen(&cp[cipherTextLen]) > SALT_SIZE - 3)
return 0;
// end NOTE.
if (pPriv->dynamic_FIXED_SALT_SIZE > 0 && ciphertext[pPriv->dynamic_SALT_OFFSET-1] != '$')
Expand Down

0 comments on commit 0de329a

Please sign in to comment.