mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
modules/webhook: Improve hmac error handling.
This commit is contained in:
parent
843f78548b
commit
725dd52185
1 changed files with 9 additions and 4 deletions
|
@ -659,14 +659,19 @@ try
|
|||
|
||||
hmac.update(content);
|
||||
|
||||
char ubuf[32];
|
||||
assert(sizeof(ubuf) >= hmac.length());
|
||||
char ubuf[64], abuf[sizeof(ubuf) * 2];
|
||||
if(unlikely(sizeof(ubuf) < hmac.length()))
|
||||
throw ircd::panic
|
||||
{
|
||||
"HMAC algorithm '%s' digest exceeds buffer size.",
|
||||
sig.first
|
||||
};
|
||||
|
||||
const const_buffer hmac_bin
|
||||
{
|
||||
hmac.finalize(ubuf)
|
||||
};
|
||||
|
||||
char abuf[64];
|
||||
static_assert(sizeof(abuf) >= sizeof(ubuf) * 2);
|
||||
const string_view hmac_hex
|
||||
{
|
||||
|
@ -679,6 +684,6 @@ catch(const crh::error &e)
|
|||
{
|
||||
throw http::error
|
||||
{
|
||||
http::NOT_IMPLEMENTED, "The signature algorithm is not supported"
|
||||
http::NOT_IMPLEMENTED, "The signature algorithm is not supported.",
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue