Since int64_t StripedBlockUtil::getInternalBlockLengt returns int64_t
|
int64_t StripedBlockUtil::getInternalBlockLength(int64_t dataSize, int32_t cellSize, |
|
int32_t numDataBlocks, int32_t idxInBlockGroup) { |
|
if (dataSize < 0 || cellSize <= 0 || numDataBlocks <= 0 || idxInBlockGroup < 0) { |
|
THROW(InvalidParameter, "invalid parameter."); |
|
} |
|
// Size of each stripe (only counting data blocks) |
|
int32_t stripeSize = cellSize * numDataBlocks; |
|
// If block group ends at stripe boundary, each internal block has an equal |
|
// share of the group |
|
int32_t lastStripeDataLen = static_cast<int32_t>(dataSize % stripeSize); |
|
if (lastStripeDataLen == 0) { |
|
return dataSize / numDataBlocks; |
|
} |
|
|
|
int32_t numStripes = static_cast<int32_t>((dataSize - 1) / stripeSize + 1); |
|
return (numStripes - 1) * cellSize |
|
+ lastCellSize(lastStripeDataLen, cellSize, numDataBlocks, idxInBlockGroup); |
|
} |
and only dataSize has int64_t
there could be integer overflow at:
|
return (numStripes - 1) * cellSize |
|
+ lastCellSize(lastStripeDataLen, cellSize, numDataBlocks, idxInBlockGroup); |
|
} |
Possible fix:
cast one of member of adddition to int64_t
Since int64_t StripedBlockUtil::getInternalBlockLengt returns int64_t
libhdfs3/src/client/StripedBlockUtil.cpp
Lines 117 to 134 in d0ae7d2
and only dataSize has int64_t
there could be integer overflow at:
libhdfs3/src/client/StripedBlockUtil.cpp
Lines 132 to 134 in d0ae7d2
Possible fix:
cast one of member of adddition to int64_t