]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Sanity checking in storeDirGetBlkSize. Currently callers don't
authorwessels <>
Wed, 28 Mar 2001 21:45:40 +0000 (21:45 +0000)
committerwessels <>
Wed, 28 Mar 2001 21:45:40 +0000 (21:45 +0000)
check for errors or abnormal values.  Make sure fs.blksize is never
zero upon returning from this function.  Use 2048 as a default
block size.

src/store_dir.cc

index 4066203acb9c416c132196199681825b844510fb..1d50285a2b9da704829b15ac836e2a78d167f244 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.128 2001/03/13 19:11:25 wessels Exp $
+ * $Id: store_dir.cc,v 1.129 2001/03/28 14:45:40 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -477,6 +477,7 @@ storeDirGetBlkSize(const char *path, int *blksize)
     struct statvfs sfs;
     if (statvfs(path, &sfs)) {
        debug(50, 1) ("%s: %s\n", path, xstrerror());
+       *blksize = 2048;
        return 1;
     }
     *blksize = (int) sfs.f_frsize;
@@ -484,10 +485,16 @@ storeDirGetBlkSize(const char *path, int *blksize)
     struct statfs sfs;
     if (statfs(path, &sfs)) {
        debug(50, 1) ("%s: %s\n", path, xstrerror());
+       *blksize = 2048;
        return 1;
     }
     *blksize = (int) sfs.f_bsize;
 #endif
+    /*
+     * Sanity check; make sure we have a meaningful value.
+     */
+    if (*blksize > 512)
+       *blksize = 2048;
     return 0;
 }