Skip to content

Commit

Permalink
check number of args before using lua stack
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolerda committed Nov 16, 2023
1 parent adfb012 commit c8b6187
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/zen_p256.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ static int p256_pubcheck(lua_State *L)

static int p256_sign(lua_State *L)
{
int n_args = lua_gettop(L);

BEGIN();
Z(L);
hash256 sha256;
Expand Down Expand Up @@ -143,7 +145,7 @@ static int p256_sign(lua_State *L)
}
sig->len = SIG_SIZE;

if(!lua_isnoneornil(L, 3)) {
if(n_args > 2) {
k = o_arg(L, 3);
if(k == NULL) {
failed_msg = "Could not allocate ephemeral key";
Expand Down

0 comments on commit c8b6187

Please sign in to comment.