Skip to content

Commit

Permalink
fix a stack overflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwii committed Nov 1, 2021
1 parent b6ed50c commit 8b8676d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bind_addr6 = ::
;bind port
bind_port = 8123
;preferred use of ipv6
ipv6_first = 1
ipv6_first = 0
;secret key
key = zfTUq4rVLgqPLAJT7tgEgft2PDfVwbI4DVnqZpM3FGA=

Expand Down
14 changes: 13 additions & 1 deletion src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,17 @@ int aes_encrypt(__const__ unsigned char *indata, __const__ int len, unsigned cha

int aes_decrypt(__const__ unsigned char *indata, __const__ int len, unsigned char *outdata, __const__ unsigned char *key)
{
return __aes_en_de_crypt(AES_DECRYPT, indata, AES_ENCRYPT_LEN(len), outdata, key);
int tmp_len = AES_ENCRYPT_LEN(len);
unsigned char *tmp_buf = malloc(tmp_len);
if(tmp_buf == NULL)
return 1;
int rtn = __aes_en_de_crypt(AES_DECRYPT, indata, tmp_len, tmp_buf, key);
if(rtn != 0)
{
free(tmp_buf);
return rtn;
}
memcpy(outdata, tmp_buf, len);
free(tmp_buf);
return rtn;
}

0 comments on commit 8b8676d

Please sign in to comment.