Skip to content

Commit

Permalink
missing some error checks on box.
Browse files Browse the repository at this point in the history
  • Loading branch information
michelp committed Jul 23, 2020
1 parent f99a7f5 commit 71ee2b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/box.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ pgsodium_crypto_box(PG_FUNCTION_ARGS)
bytea* publickey = PG_GETARG_BYTEA_P(2);
bytea* secretkey = PG_GETARG_BYTEA_P(3);
int success;
size_t message_size = crypto_box_MACBYTES + VARSIZE_ANY(message);
bytea* result = _pgsodium_zalloc_bytea(message_size);
size_t message_size;
bytea* result;
ERRORIF(VARSIZE_ANY_EXHDR(nonce) != crypto_box_NONCEBYTES, "invalid nonce");
ERRORIF(VARSIZE_ANY_EXHDR(publickey) != crypto_box_PUBLICKEYBYTES, "invalid public key");
ERRORIF(VARSIZE_ANY_EXHDR(secretkey) != crypto_box_SECRETKEYBYTES, "invalid secret key");

message_size = crypto_box_MACBYTES + VARSIZE_ANY(message);
result = _pgsodium_zalloc_bytea(message_size);
success = crypto_box_easy(
PGSODIUM_UCHARDATA(result),
PGSODIUM_UCHARDATA(message),
Expand Down

0 comments on commit 71ee2b4

Please sign in to comment.