[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Fri Jun 13 21:30:01 CEST 2008


SVN commit 820296 by asimha:


+ Making the BinFileHelper class less prone to abuse, by clearing any
previously loaded index table data.

CCMAIL: kstars-devel at kde.org



 M  +7 -0      binfilehelper.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/binfilehelper.cpp #820295:820296
@@ -57,6 +57,8 @@
     char ASCII_text[125];
     dataElement *de;
 
+    // TODO: Implement byteswapping here
+
     // Read the preamble
     if(!fileHandle) 
 	return ERR_FILEOPEN;
@@ -77,6 +79,7 @@
     // Read the field descriptor table
     fread(&nfields, 2, 1, fileHandle);
 
+    fields.clear();
     for(i = 0; i < nfields; ++i) {
 	de = new dataElement;
 	if(!fread(de, sizeof(dataElement), 1, fileHandle)) {
@@ -109,6 +112,8 @@
     prev_nrecs = 0;
     recordCount = 0;
 
+    indexCount.clear();
+    indexOffset.clear();
     for(i = 0; i < indexSize; ++i) {
 	if(!fread(&ID, 2, 1, fileHandle)) {
 	    errorMessage.sprintf("Table truncated before expected! Read i = %d index entries so far", i);
@@ -135,8 +140,10 @@
 				    (offset - prev_offset) / recordSize, offset, prev_offset, recordSize, prev_nrecs, i - 1);
 	    return ERR_INDEX_BADOFFSET;
 	}
+
 	indexOffset.append( offset );
 	indexCount.append( nrecs );
+
 	recordCount += nrecs;
 	prev_offset = offset;
 	prev_nrecs = nrecs;


More information about the Kstars-devel mailing list