From: wessels <> Date: Wed, 28 Mar 2001 21:45:40 +0000 (+0000) Subject: Sanity checking in storeDirGetBlkSize. Currently callers don't X-Git-Tag: SQUID_3_0_PRE1~1559 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b3af09f98659c1e2b475ba7eccf32ff19779b9c;p=thirdparty%2Fsquid.git Sanity checking in storeDirGetBlkSize. Currently callers don't 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. --- diff --git a/src/store_dir.cc b/src/store_dir.cc index 4066203acb..1d50285a2b 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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; }