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

Querying CDistributedSuperFile for a subfile that doesn't exist returned
a subfile instead of throwing an exception. By not throwing an error,
incorrect code that calls querySubFile may be appear to work.  This fix
modifies querySubFile so that it throws an exception when the subfile
number is not valid.

Signed-off-by: Shamser Ahmed <[email protected]>
  • Loading branch information
shamser committed Mar 19, 2024
1 parent 43962f5 commit e3f4a64
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6271,22 +6271,27 @@ class CDistributedSuperFile: public CDistributedFileBase<IDistributedSuperFile>
virtual IDistributedFile &querySubFile(unsigned idx,bool sub) override
{
CriticalBlock block (sect);
if (sub) {
ForEachItemIn(i,subfiles) {
if (sub)
{
unsigned subfilen = idx;
ForEachItemIn(i,subfiles)
{
IDistributedFile &f=subfiles.item(i);
IDistributedSuperFile *super = f.querySuperFile();
if (super) {
if (super)
{
unsigned ns = super->numSubFiles(true);
if (ns>idx)
return super->querySubFile(idx,true);
idx -= ns;
if (ns>subfilen)
return super->querySubFile(subfilen,true);
subfilen -= ns;
}
else if (idx--==0)
else if (subfilen--==0)
return f;
}
// fall through to error
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 e3f4a64

Please sign in to comment.