View | Details | Raw Unified | Return to bug 350612
Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/index/DiskIndex.java (-2 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 783-789 Link Here
783
	this.sizeOfLastChunk = this.streamBuffer[this.bufferIndex++] & 0xFF;
783
	this.sizeOfLastChunk = this.streamBuffer[this.bufferIndex++] & 0xFF;
784
	this.documentReferenceSize = this.streamBuffer[this.bufferIndex++] & 0xFF;
784
	this.documentReferenceSize = this.streamBuffer[this.bufferIndex++] & 0xFF;
785
	this.separator = (char) (this.streamBuffer[this.bufferIndex++] & 0xFF);
785
	this.separator = (char) (this.streamBuffer[this.bufferIndex++] & 0xFF);
786
786
	long fileLength = this.indexFile.length();
787
	if (this.numberOfChunks > fileLength ) {
788
		// not an accurate check, but good enough https://bugs.eclipse.org/bugs/show_bug.cgi?id=350612
789
		if (DEBUG)
790
			System.out.println("Index file is corrupted " + this.indexFile); //$NON-NLS-1$
791
		throw new IOException("Index file is corrupted " + this.indexFile); //$NON-NLS-1$
792
	}
787
	this.chunkOffsets = new int[this.numberOfChunks];
793
	this.chunkOffsets = new int[this.numberOfChunks];
788
	for (int i = 0; i < this.numberOfChunks; i++)
794
	for (int i = 0; i < this.numberOfChunks; i++)
789
		this.chunkOffsets[i] = readStreamInt(stream);
795
		this.chunkOffsets[i] = readStreamInt(stream);
Lines 793-798 Link Here
793
	int size = readStreamInt(stream);
799
	int size = readStreamInt(stream);
794
	this.categoryOffsets = new HashtableOfIntValues(size);
800
	this.categoryOffsets = new HashtableOfIntValues(size);
795
	this.categoryEnds = new HashtableOfIntValues(size);
801
	this.categoryEnds = new HashtableOfIntValues(size);
802
	if (size > fileLength) {
803
		//  not an accurate check, but good enough  https://bugs.eclipse.org/bugs/show_bug.cgi?id=350612
804
		if (DEBUG)
805
			System.out.println("Index file is corrupted " + this.indexFile); //$NON-NLS-1$
806
		throw new IOException("Index file is corrupted " + this.indexFile); //$NON-NLS-1$
807
	}
796
	char[] previousCategory = null;
808
	char[] previousCategory = null;
797
	int offset = -1;
809
	int offset = -1;
798
	for (int i = 0; i < size; i++) {
810
	for (int i = 0; i < size; i++) {

Return to bug 350612