jmestwa-coder opened a new pull request, #626:
URL: https://github.com/apache/logging-log4cxx/pull/626
# Summary
Fixes an issue where negative values provided to the BUFFERSIZE option in
ODBCAppender could be cast to an unsigned type, resulting in an unintended very
large buffer size.
## Problem
- `OptionConverter::toInt()` may return negative values (for example "-10").`
- These values were directly cast to `size_t`, causing negative values to
become large positive numbers.
## Fix
Adds a simple guard before casting to ensure negative values are not
converted to unsigned:
```cpp
int parsed = OptionConverter::toInt(value, 1);
if (parsed < 0) {
parsed = 1;
}
setBufferSize((size_t) parsed);
```
## Behaviour Impact
- No change for valid inputs.
- Only negative values are corrected.
- Existing parsing behaviour remains unchanged.
## Tests
Added `testNegativeBufferSizeOption` to verify negative values fallback to 1.
## Scope
- Limited to `ODBCAppender::setOption` (`BUFFERSIZE` path).
- No changes to parsing logic or shared utilities.
--
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]