From f55a1e2bc3ce62fce15638934c899cfbbf4171b4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 25 Sep 2024 03:09:12 +0200 Subject: [PATCH] [proxy,modules] fix integer narrow --- .../proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp b/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp index 85867982a..40fb12f00 100644 --- a/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp +++ b/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -332,7 +333,13 @@ static BOOL dump_dyn_channel_intercept(proxyPlugin* plugin, proxyData* pdata, vo WLog_ERR(TAG, "Could not write to stream"); return FALSE; } - stream.write(buffer, Stream_Length(data->data)); + const auto s = Stream_Length(data->data); + if (s > std::numeric_limits::max()) + { + WLog_ERR(TAG, "Stream length %" PRIuz " exceeds std::streamsize::max", s); + return FALSE; + } + stream.write(buffer, static_cast(s)); if (stream.fail()) { WLog_ERR(TAG, "Could not write to stream");