@@ -484,10 +484,10 @@ db_taur_NewToc(DBfile *_dbfile)
484484 toc -> dir_names [i ] = ALLOC_N (char , 12 );
485485
486486 if (taurus -> nstates < 100 ) {
487- snprintf (toc -> dir_names [i ], 12 , "state%02d" , i );
487+ snprintf (toc -> dir_names [i ], 12 , "state%02d" , i % 100 );
488488 }
489489 else {
490- snprintf (toc -> dir_names [i ], 12 , "state%03d" , i );
490+ snprintf (toc -> dir_names [i ], 12 , "state%03d" , i % 1000 );
491491 }
492492 }
493493 toc -> ndir = taurus -> nstates ;
@@ -1455,9 +1455,9 @@ db_taur_InqMeshname(DBfile *_dbfile, char const *var_name, char *mesh_name)
14551455 */
14561456 if (strcmp (var_name , "mat1" ) == 0 ) {
14571457 if (taurus -> nstates < 100 )
1458- snprintf (mesh_name , 14 , "/state%02d/mesh1" , taurus -> state );
1458+ snprintf (mesh_name , 16 , "/state%02d/mesh1" , taurus -> state % 100 );
14591459 else
1460- snprintf (mesh_name , 15 , "/state%03d/mesh1" , taurus -> state );
1460+ snprintf (mesh_name , 17 , "/state%03d/mesh1" , taurus -> state % 1000 );
14611461 return (0 );
14621462 }
14631463 }
@@ -1776,7 +1776,7 @@ db_taur_cd(TAURUSfile *taurus, char const *path)
17761776 int state ;
17771777 char * dir ;
17781778 char opath [160 ];
1779- char npath [160 ];
1779+ char npath [256 ];
17801780
17811781 /*
17821782 * Form the new path.
@@ -1786,7 +1786,7 @@ db_taur_cd(TAURUSfile *taurus, char const *path)
17861786 }
17871787 else {
17881788 db_taur_pwd (taurus , opath );
1789- snprintf (npath , 256 , "%s/%s " , opath , path );
1789+ snprintf (npath , 256 , "%.160s/%.95s " , opath , path );
17901790 }
17911791 reduce_path (npath );
17921792
@@ -1873,19 +1873,19 @@ db_taur_pwd(TAURUSfile *taurus, char *path)
18731873 else {
18741874 if (taurus -> idir == -1 ) {
18751875 if (taurus -> nstates < 100 ) {
1876- snprintf (path , 7 , "/state%02d" , taurus -> state );
1876+ snprintf (path , 10 , "/state%02d" , taurus -> state % 100 );
18771877 }
18781878 else {
1879- snprintf (path , 8 , "/state%03d" , taurus -> state );
1879+ snprintf (path , 11 , "/state%03d" , taurus -> state % 1000 );
18801880 }
18811881 }
18821882 else {
18831883 if (taurus -> nstates < 100 ) {
1884- snprintf (path , 256 , "/state%02d/%s " , taurus -> state ,
1884+ snprintf (path , 256 , "/state%02d/%.245s " , taurus -> state % 100 ,
18851885 dir_names [taurus -> idir ]);
18861886 }
18871887 else {
1888- snprintf (path , 256 , "/state%03d/%s " , taurus -> state ,
1888+ snprintf (path , 256 , "/state%03d/%.244s " , taurus -> state % 1000 ,
18891889 dir_names [taurus -> idir ]);
18901890 }
18911891 }
0 commit comments