Skip to content

Commit

Permalink
Merge pull request #4944 from rouault/fix_ossfuzz_41993
Browse files Browse the repository at this point in the history
PCIDSK: fix write heap-buffer-overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41993
  • Loading branch information
rouault committed Dec 4, 2021
2 parents 9bcef6b + 93913a8 commit 1ca6a3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frmts/pcidsk/sdk/segment/cpcidskbinarysegment.cpp
Expand Up @@ -31,6 +31,7 @@
#include "pcidsk_exception.h"
#include "core/pcidsk_utils.h"

#include <limits>
#include <vector>
#include <string>
#include <cassert>
Expand Down Expand Up @@ -73,8 +74,12 @@ void CPCIDSKBinarySegment::Load()
if (loaded_) {
return;
}
if( data_size - 1024 > static_cast<uint64_t>(std::numeric_limits<int>::max()) )
{
return ThrowPCIDSKException("too large data_size");
}

seg_data.SetSize((int)data_size - 1024);
seg_data.SetSize((int)(data_size - 1024));

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

Expand Down

0 comments on commit 1ca6a3e

Please sign in to comment.