Selaa lähdekoodia

HPCC-21488 Fix isIndexFile(IFile) crash if file missing

Check if file is missing or can't be opened

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 6 vuotta sitten
vanhempi
commit
c064b6c0b0
1 muutettua tiedostoa jossa 3 lisäystä ja 1 poistoa
  1. 3 1
      system/jhtree/ctfile.cpp

+ 3 - 1
system/jhtree/ctfile.cpp

@@ -125,9 +125,11 @@ extern jhtree_decl bool isIndexFile(IFile *file)
     try
     {
         offset_t size = file->size();
-        if (size <= sizeof(KeyHdr))
+        if (((offset_t)-1 == size) || (size <= sizeof(KeyHdr)))
             return false;
         Owned<IFileIO> io = file->open(IFOread);
+        if (!io)
+            return false;
         KeyHdr hdr;
         if (io->read(0, sizeof(hdr), &hdr) != sizeof(hdr))
             return false;