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");