Skip to content

Commit

Permalink
HPCC-31416 CDistributedSuperFile::querySubFile may return incorrect s…
Browse files Browse the repository at this point in the history
…ubfile

When sub==true and idx is not found, it should throw an exception.
Without this change, the code function did not always throw but dropped
through to return an incorrect subfile.  This incorrect behaviour has
the effect of masking bugs in the code and causing random crashes.

The fix is to ensure an exception is thrown when sub==true and idx is not
found.

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.com>
  • Loading branch information
shamser committed Mar 18, 2024
1 parent 4072317 commit 8556757
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6274,10 +6274,12 @@ class CDistributedSuperFile: public CDistributedFileBase<IDistributedSuperFile>
if (sub)
{
unsigned subfilen = idx;
ForEachItemIn(i,subfiles) {
ForEachItemIn(i,subfiles)
{
IDistributedFile &f=subfiles.item(i);
IDistributedSuperFile *super = f.querySuperFile();
if (super) {
if (super)
{
unsigned ns = super->numSubFiles(true);
if (ns>subfilen)
return super->querySubFile(subfilen,true);
Expand All @@ -6288,7 +6290,8 @@ class CDistributedSuperFile: public CDistributedFileBase<IDistributedSuperFile>
}
throw makeStringExceptionV(-1,"CDistributedSuperFile::querySubFile(%u) for superfile %s - subfile doesn't exist ", idx, logicalName.get());
}
return subfiles.item(idx);
else
return subfiles.item(idx);
}

virtual IDistributedFile *querySubFileNamed(const char *name, bool sub) override
Expand Down

0 comments on commit 8556757

Please sign in to comment.