Skip to content

Commit 2afd157

Browse files
authored
stable-25-1-4: Validate CrcMode of extreme queries in DSProxy and VDisk Skeleton (#28249)
2 parents 8616d28 + 0b6ecbf commit 2afd157

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

ydb/core/base/blobstorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,8 @@ struct TEvBlobStorage {
11281128
Y_ABORT_UNLESS(sh < id.BlobSize(),
11291129
"Please, don't read behind the end of the blob! BlobSize# %" PRIu32 " sh# %" PRIu32,
11301130
(ui32)id.BlobSize(), (ui32)sh);
1131+
Y_ABORT_UNLESS(TErasureType::IsCrcModeValid(id.CrcMode()),
1132+
"Please, set correct CrcMode for query, CrcMode# %" PRIu32, id.CrcMode());
11311133
}
11321134

11331135
TString ToString() const {

ydb/core/blobstorage/vdisk/query/query_public.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ namespace NKikimr {
138138
if (record.ExtremeQueriesSize() == 0)
139139
return false; // we need to have one
140140

141+
for (const auto& query : record.GetExtremeQueries()) {
142+
TLogoBlobID blobId = LogoBlobIDFromLogoBlobID(query.GetId());
143+
if (!TErasureType::IsCrcModeValid(blobId.CrcMode())) {
144+
// We shouldn't be able to create TEvGet request with invalid CrcMode at all
145+
// something went wrong
146+
return false;
147+
}
148+
}
149+
141150
return true;
142151
}
143152

ydb/core/erasure/erasure.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,16 @@ void TErasureType::RestoreData(ECrcMode crcMode, TDataPartSet& partSet, bool res
32063206
}
32073207
}
32083208

3209+
bool TErasureType::IsCrcModeValid(ui32 crcModeRaw) {
3210+
switch (crcModeRaw) {
3211+
case static_cast<ui32>(ECrcMode::CrcModeNone):
3212+
case static_cast<ui32>(ECrcMode::CrcModeWholePart):
3213+
return true;
3214+
default:
3215+
return false;
3216+
}
3217+
}
3218+
32093219
} // NKikimr
32103220

32113221
Y_DECLARE_OUT_SPEC(, NKikimr::TErasureType::EErasureSpecies, stream, value) {

ydb/core/erasure/erasure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ struct TErasureType {
369369
ui64 BlockSplitPartUsedSize(ui64 dataSize, ui32 partIdx) const;
370370
ui32 BlockSplitPartIndex(ui64 offset, ui64 dataSize, ui64 &outPartOffset) const;
371371
ui64 BlockSplitWholeOffset(ui64 dataSize, ui64 partIdx, ui64 offset) const;
372+
static bool IsCrcModeValid(ui32 crcModeRaw);
372373

373374
static const std::array<TString, ErasureSpeciesCount> ErasureName;
374375
protected:

0 commit comments

Comments
 (0)