From 2536727da1f3a33ab56f97fd1e4eb9aad5b4a6b2 Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Fri, 1 Mar 2024 14:10:32 +0200 Subject: Post-review changes --- mod/hmac.cxx | 4 ++-- mod/hmac.hxx | 2 +- mod/mod-ci-github.cxx | 22 ++++------------------ 3 files changed, 7 insertions(+), 21 deletions(-) (limited to 'mod') diff --git a/mod/hmac.cxx b/mod/hmac.cxx index 83a78bd..1a78b4c 100644 --- a/mod/hmac.cxx +++ b/mod/hmac.cxx @@ -7,7 +7,7 @@ using namespace butl; string brep:: compute_hmac (const options::openssl_options& o, - const vector& m, + const void* m, size_t l, const char* k) { try @@ -45,7 +45,7 @@ compute_hmac (const options::openssl_options& o, // Write the message to openssl's input. // - out.write (m.data (), m.size ()); + out.write (static_cast (m), l); out.close (); // Read the HMAC value from openssl's output. diff --git a/mod/hmac.hxx b/mod/hmac.hxx index 0f70b7e..586d0e8 100644 --- a/mod/hmac.hxx +++ b/mod/hmac.hxx @@ -22,7 +22,7 @@ namespace brep // string compute_hmac (const options::openssl_options&, - const vector& message, + const void* message, size_t len, const char* key); } diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 2473ba0..c4aaec1 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -153,7 +153,7 @@ namespace brep // from the stream twice works out to be more complicated (see also @@ // TODO item in web/server/module.hxx). // - vector body; // Change to string, use getline('\0') + string body; { // Note that even though we may not need caching right now, we may later // (e.g., to support cancel) so let's just enable it right away. @@ -162,23 +162,9 @@ namespace brep istream& is (rq.content (limit, limit)); - // Note that istream::read() sets failbit if unable to read the - // requested number of bytes. - // - is.exceptions (istream::badbit); - try { - size_t n (0); // Total bytes read. - - while (!eof (is)) - { - body.resize (n + 8192); - is.read (body.data () + n, 8192); - n += is.gcount (); - } - - body.resize (n); + getline (is, body, '\0'); } catch (const io_error& e) { @@ -195,10 +181,10 @@ namespace brep { string h ( compute_hmac (*options_, - body, + body.data (), body.size (), options_->ci_github_app_webhook_secret ().c_str ())); - if (!icasecmp (hmac, r_hmac)) + if (!icasecmp (h, hmac)) { string m ("computed HMAC does not match received HMAC"); -- cgit v1.1