View Issue Details

IDProjectCategoryView StatusLast Update
0003059FSSCPPlatform-Engine interactionpublic2014-06-14 05:10
ReporterEchelon9 Assigned ToEchelon9  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 RC3 
Target Version3.7.2 
Summary0003059: Coverity 1204289 String not null terminated in cf_search_root_pack()
DescriptionAs reported by Coverity, the loading of VP_FILE doesn't ensure the filename element of the structure is null terminated.

689 ...
690 for (i=0; i<VP_header.num_files; i++ ) {
691 VP_FILE find;
692
   
CID 1204289 (0000001 of 1): String not null terminated (STRING_NULL)6. string_null_argument: Function fread does not terminate string find.
693 fread( &find, sizeof(VP_FILE), 1, fp );
694
695 find.offset = INTEL_INT( find.offset ); //-V570
696 find.size = INTEL_INT( find.size ); //-V570
697 find.write_time = INTEL_INT( find.write_time ); //-V570
                   ...
TagsNo tags attached.

Activities

Echelon9

2014-06-14 05:04

developer   ~0015859

Testing of the simple fix, inserting the line below confirms that no VP files are missing from two runs of the Debug version (pre- and post- change).

$ diff fs2_open.log.PRE fs2_open.log.POST
5c5
< Opened log '/Users/xxxx/Library/FS2_Open/data/fs2_open.log', Sat Jun 14 15:03:55 2014 ...
---
> Opened log '/Users/xxxx/Library/FS2_Open/data/fs2_open.log', Sat Jun 14 15:15:12 2014 ...
304c304
< cfile_init() took 3790
---
> cfile_init() took 3648
345c345
< ... Log closed, Sat Jun 14 15:04:51 2014
---
> ... Log closed, Sat Jun 14 15:15:58 2014


Added line:

find.filename[sizeof(find.filename)-1] = '\0';

Echelon9

2014-06-14 05:10

developer   ~0015860

Fix committed to trunk@10808.

Related Changesets

fs2open: trunk r10808

2014-06-14 01:28

Echelon9


Ported: N/A

Details Diff
Fix Mantis 3059: Coverity 1204289 String not null terminated in cf_search_root_pack() Affected Issues
0003059
mod - /trunk/fs2_open/code/cfile/cfilesystem.cpp Diff File

Issue History

Date Modified Username Field Change
2014-06-14 05:03 Echelon9 New Issue
2014-06-14 05:03 Echelon9 Status new => assigned
2014-06-14 05:03 Echelon9 Assigned To => Echelon9
2014-06-14 05:04 Echelon9 Note Added: 0015859
2014-06-14 05:10 Echelon9 Changeset attached => fs2open trunk r10808
2014-06-14 05:10 Echelon9 Note Added: 0015860
2014-06-14 05:10 Echelon9 Status assigned => resolved
2014-06-14 05:10 Echelon9 Resolution open => fixed