For another project, please consult its home page to locate the current issue tracker.
View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0013958 | ParaView | (No Category) | public | 2013-03-22 10:17 | 2013-05-18 20:00 | ||||
Reporter | Sven Buijssen | ||||||||
Assigned To | Sebastien Jourdain | ||||||||
Priority | normal | Severity | minor | Reproducibility | have not tried | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | 4.0 | |||||||
Summary | 0013958: VisItBridge GMVReader and GMVReader plugin: incorrect handling of invalid GMV files | ||||||||
Description | ParaView git/master, builtin mode Attached are two (invalid) GMV input files with identical data, stored once in ASCII and binary form, with the exemplary flaw that they define 20 nodes and a point data array named "pressure" which should have length 20, too, but has merely length 0. 1) binary format: VisItBridge-GMVReader and GMVReader plugin are caught in an endless loop while parsing the attached file in binary GMV format, "variable.definition.too.short.binary.gmv", while the following line keeps getting printed on stdout: I/O error while reading gmv input file. In fact, both readers get stuck for any (invalid) binary GMV input file where * an AMR grid's node definition or * a polygonal mesh definition or * a polyhedral cell definition or * a point or cell data array is shorter than it is expected to be. 2) ASCII format: When importing the same data in ASCII format from "variable.definition.too.short.ascii.gmv", both VisItBridge-GMVReader and GMVReader plugin fail to detect that the point data array named "pressure" has invalid length 0 instead of the supposed 20. Given that the malloc'd memory does not get initialised, the data array imported into ParaView contains random values as a result. Same issue when importing a polygonal mesh with an incomplete set of point coordinates ("polygonal.mesh.definition.too.short.ascii.gmv"): The missing coordinate values are completed using uninitialised memory. VisIt 2.6.1 correctly detects the invalid files. Patches attached to resolve the issue. | ||||||||
Tags | No tags attached. | ||||||||
Project | TBD | ||||||||
Topic Name | gmv_reader_contribution | ||||||||
Type | incorrect functionality | ||||||||
Attached Files | variable.definition.too.short.binary.gmv [^] (692 bytes) 2013-03-22 10:17 variable.definition.too.short.ascii.gmv [^] (337 bytes) 2013-03-22 10:18 polygonal.mesh.definition.too.short.ascii.gmv [^] (210 bytes) 2013-03-22 10:18 VisItBridge-0001-BUG-Correctly-null-terminate-strings-read-from-binar.patch [^] (5,536 bytes) 2013-03-22 10:22 [Show Content] [Hide Content] From 1eee2def3e3dba9acac193b594d6f0811bf0dc22 Mon Sep 17 00:00:00 2001 From: Sven Buijssen <sven.buijssen@tu-dortmund.de> Date: Tue, 12 Mar 2013 13:14:17 +0100 Subject: [PATCH 1/2] BUG: Correctly null-terminate strings read from binary GMV files For binary GMV files with file type "ieeei[48]r[48]", i.e. character data is 8 characters long, read keywords got null-terminated at position 32 instead of 8. --- databases/GMV/gmvread.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/databases/GMV/gmvread.c b/databases/GMV/gmvread.c index 7d95c20..10a7c8a 100644 --- a/databases/GMV/gmvread.c +++ b/databases/GMV/gmvread.c @@ -2785,12 +2785,13 @@ void readvars(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(varname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(varname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(varname,"endvars",7) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(varname,charsize,CHAR,(long)charsize_in,gmvin); + *(varname+charsize_in)=(char)0; } - *(varname+charsize_in)=(char)0; if (strncmp(varname,"endvars",7) != 0) binread(&i,intsize,INT,(long)1,gmvin); } @@ -2902,12 +2903,13 @@ void readflags(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(flgname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(flgname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(flgname,"endflag",7) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(flgname,charsize,CHAR,(long)charsize_in,gmvin); + *(flgname+charsize_in)=(char)0; } - *(flgname+charsize_in)=(char)0; if (strncmp(flgname,"endflag",7) != 0) { binread(&ntypes,intsize,INT,(long)1,gmvin); @@ -3217,12 +3219,13 @@ void readtracers(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(varname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(varname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(varname,"endtrace",8) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(varname,charsize,CHAR,(long)charsize_in,gmvin); + *(varname+charsize_in)=(char)0; } - *(varname+charsize_in)=(char)0; } if (ftype == ASCII) fscanf(gmvin,"%s",varname); ioerrtst(gmvin); @@ -3878,12 +3881,13 @@ void readsurfvars(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(varname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(varname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(varname,"endsvar",7) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(varname,charsize,CHAR,(long)charsize_in,gmvin); + *(varname+charsize_in)=(char)0; } - *(varname+charsize_in)=(char)0; } if (ftype == ASCII) fscanf(gmvin,"%s",varname); ioerrtst(gmvin); @@ -4141,12 +4145,13 @@ void readvinfo(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(varname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(varname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(varname,"endvinfo",8) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(varname,charsize,CHAR,(long)charsize_in,gmvin); + *(varname+charsize_in)=(char)0; } - *(varname+charsize_in)=(char)0; if (strncmp(varname,"endvinfo",8) != 0) { binread(&nelem_line,intsize,INT,(long)1,gmvin); @@ -4278,12 +4283,13 @@ void readgroups(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(grpname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(grpname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(grpname,"endgrp",6) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(grpname,charsize,CHAR,(long)charsize_in,gmvin); + *(grpname+charsize_in)=(char)0; } - *(grpname+charsize_in)=(char)0; if (strncmp(grpname,"endgrp",6) != 0) { binread(&i,intsize,INT,(long)1,gmvin); @@ -4437,12 +4443,13 @@ void readsubvars(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(varname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(varname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(varname,"endsubv",7) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(varname,charsize,CHAR,(long)charsize_in,gmvin); + *(varname+charsize_in)=(char)0; } - *(varname+charsize_in)=(char)0; if (strncmp(varname,"endsubv",7) != 0) { binread(&i,intsize,INT,(long)1,gmvin); @@ -4657,12 +4664,13 @@ void readvects(FILE* gmvin, int ftype) if (ftype != ASCII) { binread(vectname,charsize,CHAR,(long)MAXKEYWORDLENGTH,gmvin); + *(vectname+MAXKEYWORDLENGTH)=(char)0; if (strncmp(vectname,"endvect",7) != 0 && charsize_in == 32) { fseek(gmvin,(long)(-MAXKEYWORDLENGTH),SEEK_CUR); binread(vectname,charsize,CHAR,(long)charsize_in,gmvin); + *(vectname+charsize_in)=(char)0; } - *(vectname+charsize_in)=(char)0; if (strncmp(vectname,"endvect",7) != 0) { binread(&i,intsize,INT,(long)1,gmvin); -- 1.8.2 VisItBridge-0002-BUG-13958-Detect-incompletely-defined-data-array-and.patch [^] (25,950 bytes) 2013-03-22 10:23 [Show Content] [Hide Content] From a685ede7314f1f9542ce91259183c89f45ac64d6 Mon Sep 17 00:00:00 2001 From: Sven Buijssen <sven.buijssen@tu-dortmund.de> Date: Wed, 13 Mar 2013 15:18:42 +0100 Subject: [PATCH 2/2] BUG 13958 - Detect incompletely defined data array and abruptly ending GMV files 1) When bulk-reading into arrays (from ASCII or binary file) and the expected number of items can not be read (without hitting EOF), initialise the remaining array items to zero. 2) GMV files that end abruptly do not cause endless loops and crashes any more. 3) Distinguish between file reading errors where a file ends abruptly and where it can not be read from anymore. Appropriate error message for either case. 4) Removed obsolete error code GMVABORT in favour of GMVERROR --- databases/GMV/avtGMVFileFormat.C | 1 - databases/GMV/gmvread.c | 275 ++++++++++++++++++++++++++++++--------- databases/GMV/gmvread.h | 1 - 3 files changed, 211 insertions(+), 66 deletions(-) diff --git a/databases/GMV/avtGMVFileFormat.C b/databases/GMV/avtGMVFileFormat.C index 4634704..cfe637d 100644 --- a/databases/GMV/avtGMVFileFormat.C +++ b/databases/GMV/avtGMVFileFormat.C @@ -1539,7 +1539,6 @@ avtGMVFileFormat::ReadData() break; case GMVEND: case GMVERROR: - case GMVABORT: keepGoing = false; break; } diff --git a/databases/GMV/gmvread.c b/databases/GMV/gmvread.c index 10a7c8a..64a7a73 100644 --- a/databases/GMV/gmvread.c +++ b/databases/GMV/gmvread.c @@ -486,7 +486,11 @@ int gmvread_open_fromfileskip(char *filnam) void gmvread_close() { - if (gmvinGlobal) fclose(gmvinGlobal); + if (gmvinGlobal) + { + fclose(gmvinGlobal); + gmvinGlobal = NULL; + } fromfileskip = 0; nodes_read = 0; cells_read = 0; faces_read = 0; surface_read = 0; iend = 0; swapbytes_on = 0; skipflag = 0; @@ -716,7 +720,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(NODES) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -727,7 +731,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(CELLS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -739,7 +743,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(FACES) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -750,7 +754,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(VFACES) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -761,7 +765,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(XFACES) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -772,7 +776,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(MATERIAL) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -791,7 +795,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(FLAGS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -802,7 +806,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(POLYGONS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -844,7 +848,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(NODEIDS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -855,7 +859,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(CELLIDS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } readcellids(gmvinGlobal,ftypeGlobal); @@ -865,7 +869,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(FACEIDS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } readfaceids(gmvinGlobal,ftypeGlobal); @@ -875,7 +879,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(TRACEIDS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } readtracerids(gmvinGlobal,ftypeGlobal); @@ -885,7 +889,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(SURFACE) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -896,7 +900,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(SURFMATS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -919,7 +923,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(SURFIDS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } readsurfids(gmvinGlobal,ftypeGlobal); @@ -929,7 +933,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(UNITS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -944,7 +948,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(GROUPS) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } if (fromfileflag == 1) break; @@ -974,7 +978,7 @@ void gmvread_data() /* SB: Modification due to disabled exit statement on fromfile error */ if (fromfilecheck(CELLPES) < 0) { - gmv_data.keyword = GMVABORT; + gmv_data.keyword = GMVERROR; break; } readcellpes(gmvinGlobal,ftypeGlobal); @@ -1001,7 +1005,12 @@ void gmvread_data() /* fclose(gmvinGlobal); */ } - if (gmv_data.keyword == GMVERROR) fclose(gmvinGlobal); + if (gmv_data.keyword == GMVERROR) + if (gmvinGlobal) + { + fclose(gmvinGlobal); + gmvinGlobal = NULL; + } if (readkeyword == 1 && reading_fromfile && curr_keyword == ff_keyword) endfromfile(); @@ -1022,21 +1031,48 @@ void rdints(int iarray[], int nvals, FILE* gmvin) /* */ /* Read an integer array from an ASCII text file. */ /* */ - int i; - - for (i = 0; i < nvals; i++) - { - fscanf(gmvin,"%d",&iarray[i]); - - if ((feof(gmvin) != 0) || (ferror(gmvin) != 0)) - { - fprintf(stderr,"I/O error while reading gmv input file.\n"); - gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); - SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); - gmv_data.keyword = GMVERROR; - return; + int i, j, ret_stat; + + for (i = 0; i < nvals; i++) + { + ret_stat = fscanf(gmvin,"%d",&iarray[i]); + + /* File ends abruptly or could not be read from anymore? */ + if (feof(gmvin) != 0) + { + fprintf(stderr,"%d integer values expected, but gmv input file end reached after %d.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%d integer values expected, but gmv input file end reached after %d.\n", nvals, i); + gmv_data.keyword = GMVERROR; + return; + } + if (ferror(gmvin) != 0) + { + fprintf(stderr,"I/O error while reading gmv input file.\n"); + gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); + SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); + gmv_data.keyword = GMVERROR; + return; + } + + /* File end may have not yet been reached, but format requirements could have been violated */ + if (ret_stat == 0) + { + /* Array shorter than it is supposed to be */ + fprintf(stderr,"%d integer values expected, only %d found while reading gmv input file.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%d integer values expected, only %d found while reading gmv input file.\n", nvals, i); + gmv_data.keyword = GMVERROR; + /* Initialise remainder of array */ + for (j = i; j < nvals; j++) + { + iarray[j] = 0; + } + return; } - } + } } @@ -1045,21 +1081,48 @@ void rdlongs(long iarray[], long nvals, FILE* gmvin) /* */ /* Read an integer array from an ASCII text file. */ /* */ - long i; - - for (i = 0; i < nvals; i++) - { - fscanf(gmvin,"%ld",&iarray[i]); - - if ((feof(gmvin) != 0) | (ferror(gmvin) != 0)) - { - fprintf(stderr,"I/O error while reading gmv input file.\n"); - gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); - SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); - gmv_data.keyword = GMVERROR; - return; + long i, j, ret_stat; + + for (i = 0; i < nvals; i++) + { + ret_stat = fscanf(gmvin,"%ld",&iarray[i]); + + /* File ends abruptly or could not be read from anymore? */ + if (feof(gmvin) != 0) + { + fprintf(stderr,"%ld long values expected, but gmv input file end reached after %ld.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%ld long values expected, but gmv input file end reached after %ld.\n", nvals, i); + gmv_data.keyword = GMVERROR; + return; + } + if (ferror(gmvin) != 0) + { + fprintf(stderr,"I/O error while reading gmv input file.\n"); + gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); + SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); + gmv_data.keyword = GMVERROR; + return; + } + + /* File end may have not yet been reached, but format requirements could have been violated */ + if (ret_stat == 0) + { + /* Array shorter than it is supposed to be */ + fprintf(stderr,"%ld long values expected, only %ld found while reading gmv input file.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%ld long values expected, only %ld found while reading gmv input file.\n", nvals, i); + gmv_data.keyword = GMVERROR; + /* Initialise remainder of array */ + for (j = i; j < nvals; j++) + { + iarray[j] = (long)0; + } + return; } - } + } } @@ -1068,21 +1131,48 @@ void rdfloats(double farray[], long nvals, FILE* gmvin) /* */ /* Read an integer array from an ASCII text file. */ /* */ - int i; - - for (i = 0; i < nvals; i++) - { - fscanf(gmvin,"%lf",&farray[i]); - - if ((feof(gmvin) != 0) | (ferror(gmvin) != 0)) - { - fprintf(stderr,"I/O error while reading gmv input file.\n"); - gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); - SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); - gmv_data.keyword = GMVERROR; - return; + int i, j, ret_stat; + + for (i = 0; i < nvals; i++) + { + ret_stat = fscanf(gmvin,"%lf",&farray[i]); + + /* File ends abruptly or could not be read from anymore? */ + if (feof(gmvin) != 0) + { + fprintf(stderr,"%ld double values expected, but gmv input file end reached after %d.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%ld double values expected, but gmv input file end reached after %d.\n", nvals, i); + gmv_data.keyword = GMVERROR; + return; + } + if (ferror(gmvin) != 0) + { + fprintf(stderr,"I/O error while reading gmv input file.\n"); + gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); + SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); + gmv_data.keyword = GMVERROR; + return; + } + + /* File end may have not yet been reached, but format requirements could have been violated */ + if (ret_stat == 0) + { + /* Array shorter than it is supposed to be */ + fprintf(stderr,"%ld double values expected, only %d found while reading gmv input file.\n", nvals, i); + gmv_data.errormsg = (char *)malloc(90 * sizeof(char)); + SNPRINTF(gmv_data.errormsg, 90, + "%ld double values expected, only %d found while reading gmv input file.\n", nvals, i); + gmv_data.keyword = GMVERROR; + /* Initialise remainder of array */ + for (j = i; j < nvals; j++) + { + farray[j] = 0.0; + } + return; } - } + } } @@ -1152,7 +1242,8 @@ void endfromfile() /* Reset current data. */ ftypeGlobal = ftype_sav; fromfileskip = 0; - fclose(gmvinGlobal); + if (gmvinGlobal) + fclose(gmvinGlobal); gmvinGlobal = gmvin_sav; fromfileflag = 0; reading_fromfile = 0; @@ -1815,6 +1906,8 @@ void readcells(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(daughters,lncells,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = CELLS; gmv_data.datatype = AMR; gmv_data.num = lncells; @@ -1974,6 +2067,7 @@ void readcells(FILE* gmvin, int ftype) if (ftype != ASCII) binread(nverts,intsize,INT,(long)nfaces,gmvin); if (ftype == ASCII) rdints(nverts,nfaces,gmvin); ioerrtst(gmvin); + if (gmv_data.keyword == GMVERROR) return; /* Read all face vertices, reallocate if needed. */ totverts = 0; @@ -2005,6 +2099,7 @@ void readcells(FILE* gmvin, int ftype) ioerrtst(gmvin); } if (ftype == ASCII) rdlongs(lcellnodenos,(long)totverts,gmvin); + if (gmv_data.keyword == GMVERROR) return; lfaces = (long *)malloc(nfaces*sizeof(long)); if (lfaces == NULL) { @@ -2076,6 +2171,8 @@ void readcells(FILE* gmvin, int ftype) for (i = 0; i < nfaces; i++) lfaces[i]--; */ + + if (gmv_data.keyword == GMVERROR) return; gmv_data.keyword = CELLS; if (strncmp(keyword,"vface2d",7) == 0) @@ -2127,6 +2224,7 @@ void readcells(FILE* gmvin, int ftype) gmv_data.keyword = GMVERROR; return; } + if (gmv_data.keyword == GMVERROR) return; gmv_data.keyword = CELLS; gmv_data.datatype = REGULAR; @@ -2239,6 +2337,7 @@ void readfaces(FILE* gmvin, int ftype) gmv_data.keyword = GMVERROR; return; } + if (gmv_data.keyword == GMVERROR) return; gmv_data.keyword = FACES; gmv_data.datatype = REGULAR; @@ -2361,6 +2460,7 @@ void readvfaces(FILE* gmvin, int ftype) gmv_data.keyword = GMVERROR; return; } + if (gmv_data.keyword == GMVERROR) return; gmv_data.keyword = VFACES; gmv_data.datatype = REGULAR; @@ -2449,6 +2549,7 @@ void readxfaces(FILE* gmvin, int ftype) } } ioerrtst(gmvin); + if (gmv_data.keyword == GMVERROR) return; /* Count the total number of vertices to read. */ totverts = 0; @@ -2488,6 +2589,7 @@ void readxfaces(FILE* gmvin, int ftype) } } ioerrtst(gmvin); + if (gmv_data.keyword == GMVERROR) return; gmv_data.nlongdata1 = lnfaces; gmv_data.longdata1 = nxvertsin; @@ -2534,6 +2636,7 @@ void readxfaces(FILE* gmvin, int ftype) } } ioerrtst(gmvin); + if (gmv_data.keyword == GMVERROR) return; /* Get the number of cells from the largest cell */ /* when reading the cells per face data. */ @@ -2646,6 +2749,8 @@ void readmats(FILE* gmvin, int ftype) } if (ftype == ASCII) rdints(matin,lnmatin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = MATERIAL; gmv_data.datatype = data_type; gmv_data.num = lmmats; @@ -2879,6 +2984,8 @@ void readvars(FILE* gmvin, int ftype) } if (ftype == ASCII) rdfloats(varin,(long)nvarin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = VARIABLE; gmv_data.datatype = data_type; gmv_data.num = nvarin; @@ -3000,6 +3107,8 @@ void readflags(FILE* gmvin, int ftype) } if (ftype == ASCII) rdints(flagin,nflagin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = FLAGS; gmv_data.datatype = data_type; strncpy(gmv_data.name1, flgname, MAXCUSTOMNAMELENGTH-1); @@ -3096,6 +3205,8 @@ void readpolygons(FILE* gmvin, int ftype) } if (ftype == ASCII) rdfloats(vertsin,(long)3*nvertsin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = POLYGONS; gmv_data.datatype = REGULAR; gmv_data.num = limatno; @@ -3274,6 +3385,8 @@ void readtracers(FILE* gmvin, int ftype) if (ftype == ASCII) rdfloats(lfieldtr,(long)numtracers,gmvin); } + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = TRACERS; gmv_data.datatype = TRACERDATA; strncpy(gmv_data.name1, varname, MAXCUSTOMNAMELENGTH-1); @@ -3324,6 +3437,8 @@ void readnodeids(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(lnodeids,numnodes,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = NODEIDS; gmv_data.datatype = REGULAR; gmv_data.num = numnodes; @@ -3372,6 +3487,8 @@ void readcellids(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(lcellids,numcells,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = CELLIDS; gmv_data.datatype = REGULAR; gmv_data.num = numcells; @@ -3430,6 +3547,8 @@ void readfaceids(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(lfaceids,numfaces,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = FACEIDS; gmv_data.datatype = REGULAR; gmv_data.num = numcells; @@ -3481,6 +3600,8 @@ void readtracerids(FILE* gmvin, int ftype) if (ftype == ASCII) rdlongs(ltracerids,(long)numtracers,gmvin); } + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = TRACEIDS; gmv_data.datatype = REGULAR; gmv_data.num = numtracers; @@ -3710,6 +3831,7 @@ void readsurface(FILE* gmvin, int ftype) gmv_data.keyword = GMVERROR; return; } + if (gmv_data.keyword == GMVERROR) return; gmv_data.keyword = SURFACE; gmv_data.datatype = REGULAR; @@ -3755,6 +3877,8 @@ void readsurfmats(FILE* gmvin, int ftype) } if (ftype == ASCII) rdints(matin,numsurf,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = SURFMATS; gmv_data.num = numsurf; gmv_data.nlongdata1 = numsurf; @@ -3935,6 +4059,8 @@ void readsurfvars(FILE* gmvin, int ftype) if (ftype == ASCII) rdfloats(varin,(long)numsurf,gmvin); } + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = SURFVARS; gmv_data.datatype = REGULAR; strncpy(gmv_data.name1, varname, MAXCUSTOMNAMELENGTH-1); @@ -4045,6 +4171,8 @@ void readsurfflag(FILE* gmvin, int ftype) if (ftype == ASCII) rdints(flagin,numsurf,gmvin); } + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = SURFFLAG; gmv_data.datatype = REGULAR; strncpy(gmv_data.name1, flgname, MAXCUSTOMNAMELENGTH-1); @@ -4123,6 +4251,8 @@ void readsurfids(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(lsurfids,numsurf,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = SURFIDS; gmv_data.datatype = REGULAR; gmv_data.num = numsurf; @@ -4210,6 +4340,8 @@ void readvinfo(FILE* gmvin, int ftype) if (ftype == IEEEI4R4 || ftype == IEEEI8R4) free(tmpfloat); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = VINFO; gmv_data.datatype = REGULAR; gmv_data.num = nelem_line; @@ -4362,6 +4494,8 @@ void readgroups(FILE* gmvin, int ftype) } if (ftype == ASCII) rdints(groupin,ngroupin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = GROUPS; gmv_data.datatype = data_type; strncpy(gmv_data.name1, grpname, MAXCUSTOMNAMELENGTH-1); @@ -4420,6 +4554,8 @@ void readcellpes(FILE* gmvin, int ftype) } if (ftype == ASCII) rdlongs(lcellpes,numcells,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = CELLPES; gmv_data.datatype = REGULAR; gmv_data.num = numcells; @@ -4804,6 +4940,8 @@ void readvects(FILE* gmvin, int ftype) } if (ftype == ASCII) rdfloats(vectin,(long)nreadin,gmvin); + if (gmv_data.keyword == GMVERROR) return; + gmv_data.keyword = VECTORS; gmv_data.datatype = data_type; gmv_data.num = nvectin; @@ -4856,6 +4994,7 @@ void ioerrtst(FILE *gmvin) fprintf(stderr,"I/O error while reading gmv input file.\n"); gmv_data.errormsg = (char *)malloc(40 * sizeof(char)); SNPRINTF(gmv_data.errormsg,40,"I/O error while reading gmv input file."); + gmv_data.keyword = GMVERROR; /*LLNL*/ /* exit(0); @@ -4957,6 +5096,12 @@ int binread(void* ptr, int size, int type, long nitems, FILE* stream) ret_stat = (int)fread(ptr, size, nitems, stream); + if (ret_stat < nitems) + { + /* Initialise remainder of array */ + memset((char*)ptr + size*ret_stat, '\0', size*(nitems - ret_stat)); + } + if (swapbytes_on && type != CHAR && type != WORD) swapbytes(ptr, size, nitems); @@ -5126,7 +5271,7 @@ void gmvread_mesh() /* Check for GMVERROR. */ /* SB: Modification due to disabled exit statement on fromfile error */ - if (gmv_data.keyword == GMVERROR || gmv_data.keyword == GMVABORT) + if (gmv_data.keyword == GMVERROR) { gmv_meshdata.intype = GMVERROR; return; @@ -7286,6 +7431,8 @@ void readrays(FILE* gmvrayin, int ftype) } if (ftype == ASCII) rdfloats(field, (long)nvarin, gmvrayin); + if (gmv_data.keyword == GMVERROR) return; + gmvrays[iray].field[k] = field; } if (ftype != ASCII || ftype == IEEEI4R4 || ftype == IEEEI8R4) diff --git a/databases/GMV/gmvread.h b/databases/GMV/gmvread.h index 7ce2cc0..cccbfcf 100755 --- a/databases/GMV/gmvread.h +++ b/databases/GMV/gmvread.h @@ -44,7 +44,6 @@ #define GMVEND 51 #define INVALIDKEYWORD 52 #define GMVERROR 53 -#define GMVABORT 54 /* SB: Handle cases that traditionally led to 'exit(0)' */ /* Data types for Nodes: */ -- 1.8.2 PV-0001-ENH-GMVABORT-has-become-obsolete-relying-on-GMVERROR.patch [^] (2,283 bytes) 2013-03-22 10:23 [Show Content] [Hide Content] From 3eaf6341534b5612da0a9777bed44105bb82e921 Mon Sep 17 00:00:00 2001 From: Sven Buijssen <sven.buijssen@tu-dortmund.de> Date: Wed, 13 Mar 2013 20:19:45 +0100 Subject: [PATCH] ENH: GMVABORT has become obsolete, relying on GMVERROR now gmvread.c from VisItBridge repository has been patched such that the separate return code GMVABORT added a few revision back is not required any more --- Plugins/GMVReader/vtkGMVReader.cxx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Plugins/GMVReader/vtkGMVReader.cxx b/Plugins/GMVReader/vtkGMVReader.cxx index 7ee18b3..1abf780 100644 --- a/Plugins/GMVReader/vtkGMVReader.cxx +++ b/Plugins/GMVReader/vtkGMVReader.cxx @@ -334,11 +334,7 @@ int vtkGMVReader::RequestData(vtkInformation *vtkNotUsed(request), GMVRead::gmvread_data(); switch(GMVRead::gmv_data.keyword) { -#ifdef GMVABORT - // If gmvread.c has been patched such that instead of exiting (original - // code) or disabled exiting (VisIt's variant) a decent error code is - // returned: - case (GMVABORT): + case (GMVERROR): if (GMVRead::gmv_data.errormsg != NULL) { vtkErrorMacro("" << GMVRead::gmv_data.errormsg); @@ -351,7 +347,6 @@ int vtkGMVReader::RequestData(vtkInformation *vtkNotUsed(request), // this->SetupEmptyOutput(); // this->CurrentOutput = 0; return 0; -#endif case (GMVEND): keepParsing = false; @@ -2026,11 +2021,7 @@ int vtkGMVReader::RequestInformation(vtkInformation *vtkNotUsed(request), GMVRead::gmvread_data(); switch(GMVRead::gmv_data.keyword) { -#ifdef GMVABORT - // If gmvread.c has been patched such that instead of exiting (original - // code) or disabled exiting (VisIt's variant) a decent error code is - // returned: - case (GMVABORT): + case (GMVERROR): if (GMVRead::gmv_data.errormsg != NULL) { vtkErrorMacro("" << GMVRead::gmv_data.errormsg); @@ -2043,7 +2034,6 @@ int vtkGMVReader::RequestInformation(vtkInformation *vtkNotUsed(request), // this->SetupEmptyOutput(); // this->CurrentOutput = 0; return 0; -#endif case (GMVEND): keepParsing = false; -- 1.8.2 | ||||||||
Relationships | |
Relationships |
Notes | |
(0030681) Utkarsh Ayachit (administrator) 2013-05-03 10:04 |
SUMMARY --------------------------------------------- Topics merged into master: 14040_add_save_animation_time_range gmv_reader_contribution pvw-add-jsduck-cmake-hints pvw-fix-lut-management-issue python_documentation_cleanup |
(0030718) Alan Scott (manager) 2013-05-07 20:40 |
Tested master, local server, Windows. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2013-03-22 10:17 | Sven Buijssen | New Issue | |
2013-03-22 10:17 | Sven Buijssen | File Added: variable.definition.too.short.binary.gmv | |
2013-03-22 10:18 | Sven Buijssen | File Added: variable.definition.too.short.ascii.gmv | |
2013-03-22 10:18 | Sven Buijssen | File Added: polygonal.mesh.definition.too.short.ascii.gmv | |
2013-03-22 10:22 | Sven Buijssen | File Added: VisItBridge-0001-BUG-Correctly-null-terminate-strings-read-from-binar.patch | |
2013-03-22 10:23 | Sven Buijssen | File Added: VisItBridge-0002-BUG-13958-Detect-incompletely-defined-data-array-and.patch | |
2013-03-22 10:23 | Sven Buijssen | File Added: PV-0001-ENH-GMVABORT-has-become-obsolete-relying-on-GMVERROR.patch | |
2013-05-02 13:18 | Sebastien Jourdain | Assigned To | => Sebastien Jourdain |
2013-05-02 13:18 | Sebastien Jourdain | Status | backlog => todo |
2013-05-02 13:18 | Sebastien Jourdain | Topic Name | => gmv_reader_contribution |
2013-05-02 13:18 | Sebastien Jourdain | Status | todo => gatekeeper review |
2013-05-02 13:18 | Sebastien Jourdain | Resolution | open => fixed |
2013-05-03 10:04 | Utkarsh Ayachit | Fixed in Version | => git-master |
2013-05-03 10:04 | Utkarsh Ayachit | Status | gatekeeper review => customer review |
2013-05-03 10:04 | Utkarsh Ayachit | Note Added: 0030681 | |
2013-05-07 20:40 | Alan Scott | Note Added: 0030718 | |
2013-05-07 20:40 | Alan Scott | Status | customer review => closed |
2013-05-18 20:00 | Utkarsh Ayachit | Fixed in Version | git-master => 4.0 |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |