Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 323249 - games-util/nforenum crashes when $HOME ends in a slash
Summary: games-util/nforenum crashes when $HOME ends in a slash
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Games (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Games
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-08 20:19 UTC by David Leverton
Modified: 2010-06-08 20:25 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
nforenum-0_pre2309-string.patch (nforenum-0_pre2309-string.patch,429 bytes, patch)
2010-06-08 20:19 UTC, David Leverton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Leverton 2010-06-08 20:19:26 UTC
If the value of the HOME environment variable ends in a /, nforenum dies with an assertion failure (it may not do so for all input files, but it does for ogfxe_extra.nfo from games-misc/opengfx-0.2.4):

[NFORENUM] ogfxe_extra.nfo

NFORenum v3.4.6 r0 - Copyright 2004-2009 Dale McCoy.

Processing file "ogfxe_extra.nfo".

Failed to open data file: ".renum/79Dv.dat". (21)

Is a directory

renum: data.cpp:693: FILE* tryopen(const char*, const char*, bool): Assertion `false' failed.


The problem is the following segment of code, which is run on the contents of $HOME, in an attempt to trim the trailing slash:

	if(dir[dir.length()-1]=='\\'||dir[dir.length()-1]=='/')
		dir[dir.length()-1]='\0';

Since dir is a C++ std::string, it doesn't work to overwrite the last character with a NUL - this just results in a string with a NUL as its last character.  When appending the "/.renum/79Dv.dat" part, this results in "/foo\0/.renum/79Dv.dat", then when trying to open it as a filename the kernel truncates it at the NUL and tries to open the /foo directory as a file, which fails.  The attached patch fixes this.
Comment 1 David Leverton 2010-06-08 20:19:56 UTC
Created attachment 234583 [details, diff]
nforenum-0_pre2309-string.patch

Fix
Comment 2 Mr. Bones. (RETIRED) gentoo-dev 2010-06-08 20:25:45 UTC
in portage.  thanks for the bug report and patch.