فهرست منبع

Merge pull request #13572 from jakesmith/hpcc-23806-isCompressedIndex-mod0

HPCC-23806 Fix mod by 0 issues testing indexes

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 سال پیش
والد
کامیت
2ccbdf0b9f
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      system/jhtree/ctfile.cpp

+ 2 - 2
system/jhtree/ctfile.cpp

@@ -106,7 +106,7 @@ extern bool isCompressedIndex(const char *filename)
         if (io->read(0, sizeof(hdr), &hdr) == sizeof(hdr))
         {
             SwapBigEndian(hdr);
-            if (size % hdr.nodeSize == 0 && hdr.phyrec == size-1 && hdr.root && hdr.root % hdr.nodeSize == 0 && hdr.ktype & (HTREE_COMPRESSED_KEY|HTREE_QUICK_COMPRESSED_KEY))
+            if (hdr.nodeSize && (size % hdr.nodeSize == 0) && (hdr.phyrec == size-1) && hdr.root && (hdr.root % hdr.nodeSize == 0) && (hdr.ktype & (HTREE_COMPRESSED_KEY|HTREE_QUICK_COMPRESSED_KEY)))
             {
                 NodeHdr root;
                 if (io->read(hdr.root, sizeof(root), &root) == sizeof(root))
@@ -843,7 +843,7 @@ extern jhtree_decl void validateKeyFile(const char *filename, offset_t nodePos)
     _WINREV(hdr.nodeSize);
     if (hdr.phyrec != size-1)
         throw MakeStringException(5, "Invalid key %s: phyrec was %" I64F "d, expected %" I64F "d", filename, hdr.phyrec, size-1);
-    if (size % hdr.nodeSize)
+    if (!hdr.nodeSize || size % hdr.nodeSize)
         throw MakeStringException(3, "Invalid key %s: size %" I64F "d is not a multiple of key node size (%d)", filename, size, hdr.nodeSize);
     if (!hdr.root || hdr.root % hdr.nodeSize !=0)
         throw MakeStringException(6, "Invalid key %s: invalid root pointer %" I64F "x", filename, hdr.root);