Avoid null SEGV if libargon passed string with too few $

Seen on netbsd-9 built xscreensaver running on a current system.
Whatever triggered this should also be fixed, but in the meantime
we can improve the behaviour from "Segmentation Fault"
This commit is contained in:
abs 2022-05-29 10:58:09 +00:00
parent c9667e8120
commit 04799ba54b
1 changed files with 6 additions and 2 deletions

View File

@ -335,13 +335,17 @@ decode_option(argon2_context *ctx, argon2_type *atype, const char *option)
}
a = strsep(&inp, "$");
if (a == null) {
free(in);
return -1;
}
sl = ctx->saltlen;
if (from_base64(ctx->salt, &sl, a) == NULL) {
free(in);
free(in);
return -1;
}
}
ctx->saltlen = sl;