From ae1923e36260ff59efb85dda99b5345341bff6d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 10 Jun 2009 18:08:19 +0000 Subject: [PATCH] windows-cache-validation-20090610 LICENSE MIT correct cell validation to avoid false detection of infinite loops if a cm_cell_t object had to be freed. add newlines to output of volumeHashTableSize and cellHashTableSize --- src/WINNT/afsd/cm_cell.c | 16 ++++++++-------- src/WINNT/afsd/cm_memmap.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/WINNT/afsd/cm_cell.c b/src/WINNT/afsd/cm_cell.c index 68ed0229f..7c3f74c21 100644 --- a/src/WINNT/afsd/cm_cell.c +++ b/src/WINNT/afsd/cm_cell.c @@ -457,32 +457,32 @@ long cm_ValidateCell(void) { cm_cell_t * cellp; - afs_uint32 count; + afs_uint32 count1, count2; - for (cellp = cm_data.allCellsp, count = 0; cellp; cellp=cellp->allNextp, count++) { + for (cellp = cm_data.allCellsp, count1 = 0; cellp; cellp=cellp->allNextp, count1++) { if ( cellp->magic != CM_CELL_MAGIC ) { afsi_log("cm_ValidateCell failure: cellp->magic != CM_CELL_MAGIC"); fprintf(stderr, "cm_ValidateCell failure: cellp->magic != CM_CELL_MAGIC\n"); return -1; } - if ( count != 0 && cellp == cm_data.allCellsp || - count > cm_data.maxCells ) { + if ( count1 != 0 && cellp == cm_data.allCellsp || + count1 > cm_data.maxCells ) { afsi_log("cm_ValidateCell failure: cm_data.allCellsp infinite loop"); fprintf(stderr, "cm_ValidateCell failure: cm_data.allCellsp infinite loop\n"); return -2; } } - for (cellp = cm_data.freeCellsp; cellp; cellp=cellp->freeNextp, count++) { - if ( count != 0 && cellp == cm_data.freeCellsp || - count > cm_data.maxCells ) { + for (cellp = cm_data.freeCellsp, count2 = 0; cellp; cellp=cellp->freeNextp, count2++) { + if ( count2 != 0 && cellp == cm_data.freeCellsp || + count2 > cm_data.maxCells ) { afsi_log("cm_ValidateCell failure: cm_data.freeCellsp infinite loop"); fprintf(stderr, "cm_ValidateCell failure: cm_data.freeCellsp infinite loop\n"); return -3; } } - if ( count != cm_data.currentCells ) { + if ( (count1 + count2) != cm_data.currentCells ) { afsi_log("cm_ValidateCell failure: count != cm_data.currentCells"); fprintf(stderr, "cm_ValidateCell failure: count != cm_data.currentCells\n"); return -4; diff --git a/src/WINNT/afsd/cm_memmap.c b/src/WINNT/afsd/cm_memmap.c index c0473b34f..bf9767cb6 100644 --- a/src/WINNT/afsd/cm_memmap.c +++ b/src/WINNT/afsd/cm_memmap.c @@ -424,10 +424,10 @@ cm_ValidateMappedMemory(char * cachePath) fprintf(stderr," blockSize = %u\n", config_data_p->blockSize); fprintf(stderr," bufferSize = %I64u\n", config_data_p->bufferSize); fprintf(stderr," cacheType = %u\n", config_data_p->cacheType); - fprintf(stderr," volumeHashTableSize = %u", config_data_p->volumeHashTableSize); + fprintf(stderr," volumeHashTableSize = %u\n", config_data_p->volumeHashTableSize); fprintf(stderr," currentVolumes = %u\n", config_data_p->currentVolumes); fprintf(stderr," maxVolumes = %u\n", config_data_p->maxVolumes); - fprintf(stderr," cellHashTableSize = %u", config_data_p->cellHashTableSize); + fprintf(stderr," cellHashTableSize = %u\n", config_data_p->cellHashTableSize); fprintf(stderr," currentCells = %u\n", config_data_p->currentCells); fprintf(stderr," maxCells = %u\n", config_data_p->maxCells); fprintf(stderr," scacheHashTableSize = %u\n", config_data_p->scacheHashTableSize); -- 2.39.5