From: wessels <> Date: Fri, 13 Oct 2000 12:35:05 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1814 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=faec503cc8642059f3c6fb5b5ca6e7dac70b70f4;p=thirdparty%2Fsquid.git DW: - We have to test the bit before calling file_map_bit_reset. file_map_bit_reset doesn't do bounds checking. It assumes filn is a valid file number, but it might not be because the map is dynamic in size. Also clearing an already clear bit puts the map counter of-of-whack. Damn, been looking for that bug for a long time. - gindent for good measure. --- diff --git a/src/fs/aufs/store_dir_aufs.cc b/src/fs/aufs/store_dir_aufs.cc index ad1da3c76e..f5d877588e 100644 --- a/src/fs/aufs/store_dir_aufs.cc +++ b/src/fs/aufs/store_dir_aufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.7 2000/06/27 22:06:23 hno Exp $ + * $Id: store_dir_aufs.cc,v 1.8 2000/10/13 06:35:05 wessels Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -152,7 +152,15 @@ storeAufsDirMapBitReset(SwapDir * SD, int fn) sfileno filn = fn; aioinfo_t *aioinfo; aioinfo = (aioinfo_t *) SD->fsdata; - file_map_bit_reset(aioinfo->map, filn); + /* + * We have to test the bit before calling file_map_bit_reset. + * file_map_bit_reset doesn't do bounds checking. It assumes + * filn in a valid file number, but it might not be because + * the map is dynamic in size. Also clearing an already clear + * bit puts the map counter of-of-whack. + */ + if (file_map_bit_test(aioinfo->map, filn)) + file_map_bit_reset(aioinfo->map, filn); } int @@ -348,9 +356,9 @@ storeAufsDirInit(SwapDir * sd) { static int started_clean_event = 0; static const char *errmsg = - "\tFailed to verify one of the swap directories, Check cache.log\n" - "\tfor details. Run 'squid -z' to create swap directories\n" - "\tif needed, or if running Squid for the first time."; + "\tFailed to verify one of the swap directories, Check cache.log\n" + "\tfor details. Run 'squid -z' to create swap directories\n" + "\tif needed, or if running Squid for the first time."; storeAufsDirInitBitmap(sd); if (storeAufsDirVerifyCacheDirs(sd) < 0) fatal(errmsg); @@ -1270,8 +1278,8 @@ storeAufsDirValidFileno(SwapDir * SD, sfileno filn, int flag) * be considered invalid. */ if (flag) - if (filn > aioinfo->map->max_n_files) - return 0; + if (filn > aioinfo->map->max_n_files) + return 0; return 1; } diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index 7e06f48192..223ccd1da2 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.18 2000/10/06 05:21:58 wessels Exp $ + * $Id: store_dir_diskd.cc,v 1.19 2000/10/13 06:35:19 wessels Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -165,7 +165,15 @@ storeDiskdDirMapBitReset(SwapDir * SD, int fn) sfileno filn = fn; diskdinfo_t *diskdinfo; diskdinfo = SD->fsdata; - file_map_bit_reset(diskdinfo->map, filn); + /* + * We have to test the bit before calling file_map_bit_reset. + * file_map_bit_reset doesn't do bounds checking. It assumes + * filn in a valid file number, but it might not be because + * the map is dynamic in size. Also clearing an already clear + * bit puts the map counter of-of-whack. + */ + if (file_map_bit_test(diskdinfo->map, filn)) + file_map_bit_reset(diskdinfo->map, filn); } int diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 385c6ad607..463221c934 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.7 2000/06/27 22:06:26 hno Exp $ + * $Id: store_dir_ufs.cc,v 1.8 2000/10/13 06:35:21 wessels Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -152,7 +152,15 @@ storeUfsDirMapBitReset(SwapDir * SD, int fn) sfileno filn = fn; ufsinfo_t *ufsinfo; ufsinfo = (ufsinfo_t *) SD->fsdata; - file_map_bit_reset(ufsinfo->map, filn); + /* + * We have to test the bit before calling file_map_bit_reset. + * file_map_bit_reset doesn't do bounds checking. It assumes + * filn in a valid file number, but it might not be because + * the map is dynamic in size. Also clearing an already clear + * bit puts the map counter of-of-whack. + */ + if (file_map_bit_test(ufsinfo->map, filn)) + file_map_bit_reset(ufsinfo->map, filn); } int @@ -348,9 +356,9 @@ storeUfsDirInit(SwapDir * sd) { static int started_clean_event = 0; static const char *errmsg = - "\tFailed to verify one of the swap directories, Check cache.log\n" - "\tfor details. Run 'squid -z' to create swap directories\n" - "\tif needed, or if running Squid for the first time."; + "\tFailed to verify one of the swap directories, Check cache.log\n" + "\tfor details. Run 'squid -z' to create swap directories\n" + "\tif needed, or if running Squid for the first time."; storeUfsDirInitBitmap(sd); if (storeUfsDirVerifyCacheDirs(sd) < 0) fatal(errmsg);