diff options
-rw-r--r-- | mod/hmac.cxx | 4 | ||||
-rw-r--r-- | mod/hmac.hxx | 2 | ||||
-rw-r--r-- | mod/mod-ci-github.cxx | 22 |
3 files changed, 7 insertions, 21 deletions
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<char>& 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<const char*> (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<char>& 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<char> 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"); |