Skip to content

Commit

Permalink
netCDFVariable::GetBlockSize(): fix heap buffer write overflow on 2D …
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 25, 2021
1 parent db196a8 commit da32682
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gdal/frmts/netcdf/netcdfmultidim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3077,11 +3077,14 @@ double netCDFVariable::GetOffset(bool* pbHasOffset, GDALDataType* peStorageType)

std::vector<GUInt64> netCDFVariable::GetBlockSize() const
{
std::vector<GUInt64> res(GetDimensionCount());
const auto nDimCount = GetDimensionCount();
std::vector<GUInt64> res(nDimCount);
if( res.empty() )
return res;
int nStorageType = 0;
std::vector<size_t> anTemp(GetDimensionCount());
// We add 1 to the dimension count, for 2D char variables that we
// expose as a 1D variable.
std::vector<size_t> anTemp(1 + nDimCount);
nc_inq_var_chunking(m_gid, m_varid, &nStorageType, &anTemp[0]);
if( nStorageType == NC_CHUNKED )
{
Expand Down

0 comments on commit da32682

Please sign in to comment.