Skip to content

Commit

Permalink
Fix dynamic-stack-buffer-overflow of cachekey plugin (apache#7945)
Browse files Browse the repository at this point in the history
* Fix dynamic-stack-buffer-overflow of cachekey plugin

* Check dst_size include null termination

(cherry picked from commit 5a9339d)
(cherry picked from commit b3b7db7)
  • Loading branch information
masaori335 authored and Mark Torluemke committed Jun 22, 2021
1 parent 2130c96 commit 887f4ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/cachekey/cachekey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ appendEncoded(String &target, const char *s, size_t len)
return;
}

char tmp[len * 2];
char tmp[len * 3 + 1];
size_t written;

/* The default table does not encode the comma, so we need to use our own table here. */
Expand Down
2 changes: 1 addition & 1 deletion proxy/logging/LogUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ escapify_url_common(Arena *arena, char *url, size_t len_in, int *len_out, char *
//
size_t out_len = len_in + 2 * count;

if (dst && out_len > dst_size) {
if (dst && (out_len + 1) > dst_size) {
*len_out = 0;
return nullptr;
}
Expand Down

0 comments on commit 887f4ec

Please sign in to comment.