metsw24-max opened a new pull request, #656:
URL: https://github.com/apache/logging-log4cxx/pull/656
Normalize invalid `FileAppender` buffer size values before storing them in
the internal `int` buffer size field.
`FileAppender::_priv->bufferSize` is stored as an `int`, but multiple code
paths accepted larger or negative values without validation. On 64-bit systems,
oversized values such as `2G` could overflow during narrowing conversion and
later expand into extremely large `size_t` values during buffered writer
initialization, preventing flush thresholds from triggering and causing
unbounded memory growth.
## Changes Made
* Added validation for `BUFFERSIZE` values parsed via
`OptionConverter::toFileSize()`.
* Invalid values (negative or greater than `INT_MAX`) now:
* emit a `LogLog::warn`
* fall back to the default `8 KiB` buffer size.
* Added bounds checking in `setFileInternal()` before narrowing `size_t` to
`int`.
* Updated `setBufferSize(int)` to normalize negative inputs to `0` with a
warning.
* Added `<limits>` for safe integer boundary checks.
## Tests Added
Added regression tests covering:
* Negative `BUFFERSIZE` option values.
* Oversized `BUFFERSIZE` option values (`2G` overflow path).
* Direct negative `setBufferSize(int)` calls.
Each test verifies that the resulting buffer size remains non-negative and
does not pass through signed/unsigned reinterpretation paths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]