0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

modules/webhook: Improve hmac error handling.

This commit is contained in:
Jason Volk 2019-02-05 19:03:25 -08:00
parent 843f78548b
commit 725dd52185

View file

@ -659,14 +659,19 @@ try
hmac.update(content); hmac.update(content);
char ubuf[32]; char ubuf[64], abuf[sizeof(ubuf) * 2];
assert(sizeof(ubuf) >= hmac.length()); if(unlikely(sizeof(ubuf) < hmac.length()))
throw ircd::panic
{
"HMAC algorithm '%s' digest exceeds buffer size.",
sig.first
};
const const_buffer hmac_bin const const_buffer hmac_bin
{ {
hmac.finalize(ubuf) hmac.finalize(ubuf)
}; };
char abuf[64];
static_assert(sizeof(abuf) >= sizeof(ubuf) * 2); static_assert(sizeof(abuf) >= sizeof(ubuf) * 2);
const string_view hmac_hex const string_view hmac_hex
{ {
@ -679,6 +684,6 @@ catch(const crh::error &e)
{ {
throw http::error throw http::error
{ {
http::NOT_IMPLEMENTED, "The signature algorithm is not supported" http::NOT_IMPLEMENTED, "The signature algorithm is not supported.",
}; };
} }