Mercurial > hg > orthanc
changeset 6662:344064be379d machine-spirits
added security check in ChunkedBuffer for 32bit architectures
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sun, 22 Mar 2026 11:18:49 +0100 |
| parents | be4a4f1ccaf4 |
| children | c00c3d82289c |
| files | OrthancFramework/Sources/ChunkedBuffer.cpp |
| diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/ChunkedBuffer.cpp Sun Mar 22 11:05:50 2026 +0100 +++ b/OrthancFramework/Sources/ChunkedBuffer.cpp Sun Mar 22 11:18:49 2026 +0100 @@ -49,6 +49,15 @@ void ChunkedBuffer::AddChunkInternal(const void* chunkData, size_t chunkSize) { + { + uint64_t resultingSize = static_cast<uint64_t>(numBytes_) + static_cast<uint64_t>(chunkSize); + if (static_cast<uint64_t>(static_cast<size_t>(resultingSize)) != resultingSize) + { + // Guard for 32bit architectures + throw OrthancException(ErrorCode_NotEnoughMemory); + } + } + if (chunkSize == 0) { return;
