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 <shamser.ahmed@lexisnexis.com>
  • Loading branch information
shamser committed Mar 7, 2024
1 parent 26b7c0a commit 6773c3c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6271,20 +6271,22 @@ class CDistributedSuperFile: public CDistributedFileBase<IDistributedSuperFile>
virtual IDistributedFile &querySubFile(unsigned idx,bool sub) override
{
CriticalBlock block (sect);
if (sub) {
if (sub)
{
unsigned subfilen = idx;
ForEachItemIn(i,subfiles) {
IDistributedFile &f=subfiles.item(i);
IDistributedSuperFile *super = f.querySuperFile();
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);
}
Expand Down

0 comments on commit 6773c3c

Please sign in to comment.