Skip to content

Commit

Permalink
Bug#34991760 query_rewrite_plugins.logging_general_raw test crashes w…
Browse files Browse the repository at this point in the history
…ith FORTIFY_SOURCE=3

A digest in the query rewrite plugin is always 32 bytes long.
Fix bad arguments to snprintf.

Change-Id: Ib46855206384fb4c23b3850502ad0c19e612c831
(cherry picked from commit bcf84d9cc1963b255eb04ff1a3741e40ea055f77)
  • Loading branch information
Tor Didriksen committed Jan 19, 2023
1 parent 4c8b502 commit 2ff216c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugin/rewriter/services.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ using std::string;
namespace services {

string print_digest(const unsigned char *digest) {
const size_t string_size = PARSER_SERVICE_DIGEST_LENGTH * 2;
char digest_str[string_size + sizeof('\0')];
char digest_str[2 * PARSER_SERVICE_DIGEST_LENGTH + 1];
for (int i = 0; i < PARSER_SERVICE_DIGEST_LENGTH; ++i)
snprintf(digest_str + i * 2, string_size, "%02x", digest[i]);
sprintf(digest_str + i * 2, "%02x", digest[i]);
return digest_str;
}

Expand Down

0 comments on commit 2ff216c

Please sign in to comment.