View Issue Details

IDProjectCategoryView StatusLast Update
0003097FSSCPtablespublic2014-08-18 09:12
Reporterniffiwan Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 RC3 
Target Version3.7.2 
Summary0003097: valgrind parse error when starting WoD
Description==6917== Conditional jump or move depends on uninitialised value(s)
==6917== at 0x76667C: end_string_at_first_hash_symbol(char*) (parselo.cpp:3990)
==6917== by 0x82B8C1: ship_info_lookup(char const*) (ship.cpp:11964)
==6917== by 0x808025: parse_ship(char const*, bool) (ship.cpp:1051)
==6917== by 0x812868: parse_shiptbl(char const*) (ship.cpp:4157)
==6917== by 0x813071: ship_init() (ship.cpp:4329)
==6917== by 0x40FDFE: game_init() (freespace.cpp:2013)
==6917== by 0x4197A6: game_main(char*) (freespace.cpp:7086)
==6917== by 0x419AB0: main (freespace.cpp:7277)
Steps To ReproduceUse valgrind to run FSO with Wings of Dawn as the selected mod. Note the error being logged prior to the intro cutscene playing.

Here's the function reported by valgrind:

bool end_string_at_first_hash_symbol(char *src)
{
    char *p;
    Assert(src);

    p = get_pointer_to_first_hash_symbol(src);
    if (p)
    {
        while (*(p-1) == ' ')
            p--;

        *p = '\0';
        return true;
    }

    return false;
}
Additional InformationThe source is this ship table entry:

$Name: #NavMarker
$Short name: BEEP
$Species: LSF
+Tech Description:
XSTR("VIRTUAL NAVIGATIONAL MARKER", -1)
$end_multi_text
$POF file: navmarker.pof
(etc)

The 1st char is a # so the function attempts to read beyond the start of the string. Of course the chances of this randomly being a space and thus triggering a write of invalid memory are very low.
TagsNo tags attached.

Activities

niffiwan

2014-08-18 09:10

developer  

mantis3097-svn.patch (355 bytes)   
Index: code/parse/parselo.cpp
===================================================================
--- code/parse/parselo.cpp	(revision 11008)
+++ code/parse/parselo.cpp	(working copy)
@@ -3987,7 +3987,7 @@
 	p = get_pointer_to_first_hash_symbol(src);
 	if (p)
 	{
-		while (*(p-1) == ' ')
+		while ((p != src) && (*(p-1) == ' '))
 			p--;
 
 		*p = '\0';
mantis3097-svn.patch (355 bytes)   

niffiwan

2014-08-18 09:12

developer   ~0016236

Fix committed to trunk@11009.

Related Changesets

fs2open: trunk r11009

2014-08-18 05:41

niffiwan


Ported: N/A

Details Diff
Fix mantis 3097 (valgrind)

Don't read past the start of the string
Affected Issues
0003097
mod - /trunk/fs2_open/code/parse/parselo.cpp Diff File

Issue History

Date Modified Username Field Change
2014-08-18 09:07 niffiwan New Issue
2014-08-18 09:07 niffiwan Status new => assigned
2014-08-18 09:07 niffiwan Assigned To => niffiwan
2014-08-18 09:07 niffiwan Steps to Reproduce Updated
2014-08-18 09:10 niffiwan File Added: mantis3097-svn.patch
2014-08-18 09:12 niffiwan Changeset attached => fs2open trunk r11009
2014-08-18 09:12 niffiwan Note Added: 0016236
2014-08-18 09:12 niffiwan Status assigned => resolved
2014-08-18 09:12 niffiwan Resolution open => fixed