Skip to content

Commit 1ca6a3e

Browse files
authored
Merge pull request #4944 from rouault/fix_ossfuzz_41993
PCIDSK: fix write heap-buffer-overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41993
2 parents 9bcef6b + 93913a8 commit 1ca6a3e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: frmts/pcidsk/sdk/segment/cpcidskbinarysegment.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "pcidsk_exception.h"
3232
#include "core/pcidsk_utils.h"
3333

34+
#include <limits>
3435
#include <vector>
3536
#include <string>
3637
#include <cassert>
@@ -73,8 +74,12 @@ void CPCIDSKBinarySegment::Load()
7374
if (loaded_) {
7475
return;
7576
}
77+
if( data_size - 1024 > static_cast<uint64_t>(std::numeric_limits<int>::max()) )
78+
{
79+
return ThrowPCIDSKException("too large data_size");
80+
}
7681

77-
seg_data.SetSize((int)data_size - 1024);
82+
seg_data.SetSize((int)(data_size - 1024));
7883

7984
ReadFromFile(seg_data.buffer, 0, data_size - 1024);
8085

0 commit comments

Comments
 (0)