This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 49dfc0506e ESI: fix possible integer overflow issues (#12479)
49dfc0506e is described below
commit 49dfc0506ea4114e7c596fec39c718bf5cac89b0
Author: Brian Neradt <[email protected]>
AuthorDate: Mon Sep 8 10:08:22 2025 -0500
ESI: fix possible integer overflow issues (#12479)
This applies the fix from #12478 to the ESI plugin as well.
---
plugins/esi/esi.cc | 7 ++++---
plugins/esi/lib/EsiGunzip.h | 5 +++--
plugins/esi/lib/EsiGzip.cc | 2 +-
plugins/esi/lib/EsiGzip.h | 7 ++++---
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/plugins/esi/esi.cc b/plugins/esi/esi.cc
index a93eae0ab2..fe277ec6f8 100644
--- a/plugins/esi/esi.cc
+++ b/plugins/esi/esi.cc
@@ -27,6 +27,7 @@
#include <cstdlib>
#include <climits>
#include <cstring>
+#include <cinttypes>
#include <string>
#include <list>
#include <new>
@@ -872,8 +873,8 @@ transformData(TSCont contp)
// should not set any fixed length
if (cont_data->curr_state == ContData::PROCESSING_COMPLETE) {
if (cont_data->gzip_output) {
- string cdata;
- int downstream_length;
+ string cdata;
+ int64_t downstream_length;
if (!cont_data->esi_gzip->stream_finish(cdata, downstream_length)) {
TSError("[esi][%s] Error while finishing gzip", __FUNCTION__);
return 0;
@@ -886,7 +887,7 @@ transformData(TSCont contp)
TSError("[esi][%s] Error while writing bytes to downstream VC",
__FUNCTION__);
return 0;
}
- CONT_DATA_DBG(cont_data, "[%s] ESI processed overall/gzip: %d",
__FUNCTION__, downstream_length);
+ CONT_DATA_DBG(cont_data, "[%s] ESI processed overall/gzip: %"
PRId64, __FUNCTION__, downstream_length);
TSVIONBytesSet(cont_data->output_vio, downstream_length);
}
} else {
diff --git a/plugins/esi/lib/EsiGunzip.h b/plugins/esi/lib/EsiGunzip.h
index e9108c239b..b8467403f9 100644
--- a/plugins/esi/lib/EsiGunzip.h
+++ b/plugins/esi/lib/EsiGunzip.h
@@ -25,6 +25,7 @@
#include <zlib.h>
#include <string>
+#include <cinttypes>
class EsiGunzip
{
@@ -44,8 +45,8 @@ public:
bool stream_finish();
private:
- int _downstream_length;
- int _total_data_length;
+ int64_t _downstream_length;
+ int64_t _total_data_length;
z_stream _zstrm;
bool _init;
diff --git a/plugins/esi/lib/EsiGzip.cc b/plugins/esi/lib/EsiGzip.cc
index d860fd8d16..789b79d84e 100644
--- a/plugins/esi/lib/EsiGzip.cc
+++ b/plugins/esi/lib/EsiGzip.cc
@@ -112,7 +112,7 @@ EsiGzip::stream_encode(const char *data, int data_len,
std::string &cdata)
}
bool
-EsiGzip::stream_finish(std::string &cdata, int &downstream_length)
+EsiGzip::stream_finish(std::string &cdata, int64_t &downstream_length)
{
if (_downstream_length == 0) {
// We need to run encode first to get the gzip header inserted.
diff --git a/plugins/esi/lib/EsiGzip.h b/plugins/esi/lib/EsiGzip.h
index 037f3e4788..fc8204ae10 100644
--- a/plugins/esi/lib/EsiGzip.h
+++ b/plugins/esi/lib/EsiGzip.h
@@ -26,6 +26,7 @@
#include <zlib.h>
#include <string>
#include <string_view>
+#include <cinttypes>
class EsiGzip
{
@@ -60,16 +61,16 @@ public:
*
* @return True if the compression succeeded, false otherwise.
*/
- bool stream_finish(std::string &cdata, int &downstream_length);
+ bool stream_finish(std::string &cdata, int64_t &downstream_length);
private:
/** The cumulative total number of bytes for the compressed stream. */
- int _downstream_length;
+ int64_t _downstream_length;
/** The cumulative total number of uncompressed bytes that have been
* compressed.
*/
- int _total_data_length;
+ int64_t _total_data_length;
z_stream _zstrm;
uLong _crc;
};