VOGONS


First post, by romek41

User metadata
Rank Newbie
Rank
Newbie

Hi there! I have found a bug in a DOSBox shell. In my dosbox.conf file, in the [autoexec] section I've got only two lines, similar to this:

mount -t dir c /path/to/my/c/directory
set PATH=z:\;c:\;c:\dn;

In the 'DN' directory I've got DOS NAVIGATOR installed (there is a file called DN.COM in the DN directory), all the games are in subdirectories in 'GAMES' directory. After starting DOSBox I type:

Z:\>c:
C:\>cd games
C:\GAMES>dn

This should obviously launch DN.COM located in the C:\DN directory, but instead of this it just says:

Illegal command: c:\dn\c:\dn\c:\dn\c:\dn.COM.BAT.EXE.BAT.BAT.BAT.

My system is Aurox Linux 9.1 (polish Linux distribution, based on RedHat 9.0, with the same kernel, glibc and gcc binaries) on ext3 filesystem, DOSBox 0.61 (but this bug still exists in CVS version I've downloaded not so long ago), Athlon XP1800+ with 256MB RAM. I have tried to investigate this bug myself and I think it exists in method 'localDrive::FileExists' in file 'drive_local.cpp'. The problem is, that Linux (unlike Windows) treats directories like normal files, you can even fopen it (and I think this is the reason, why I couldn't reproduce this bug using Windows...). Let's change this function a bit:

#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>

bool localDrive::FileExists(const char* name) {
char newname[CROSS_LEN];
struct stat temp_stat;
strcpy(newname,basedir);
strcat(newname,name);
CROSS_FILENAME(newname);
dirCache.ExpandName(newname);
if(stat(newname, &temp_stat)!=0) return false;
if(S_ISREG(temp_stat.st_mode)) return true;
return false;
}

Now it seems to work correct (well, I hope it also works under Windows 😀.

Roman Standzikowski <romek41 at interia dot pl>

Reply 1 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

you are partly right.
But the filename it tries is a bit weird as well. Seems like 2 problems in one.

I think there is some string error as well as that filename should never be tested.

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 6, by romek41

User metadata
Rank Newbie
Rank
Newbie

Hmm, perhaps sometjing is wrong in the file 'shell_misc.cpp', method 'DOS_Shell::Which'. Starting from line 473 (DOSBox 0.61) it contains code:

473: if(Bitu len=strlen(path)){
474: if(path[strlen(path)-1]!='\\') strcat(path,"\\");
475: strcat(path,name);
476: strcpy(which_ret,path);
477: if (DOS_FileExists(which_ret)) return which_ret;
478: strcpy(which_ret,path);
479: strcat(which_ret,com_ext);
480: if (DOS_FileExists(which_ret)) return which_ret;

The next lines checks for exe and bat files. But I don't have any idea why lines 475-477 are there...

Reply 3 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

that group of code is correct.

i tried to reproduce your error

i did the folowing:

path=z:\;c:\util

in c:\util is a util.exe
that one is started fine.
What is your compiler version ?

Water flows down the stream
How to ask questions the smart way!

Reply 4 of 6, by romek41

User metadata
Rank Newbie
Rank
Newbie

I've got gcc 3.2.2-5 (from Red Hat). I could also observe this bug on Gentoo 2004.0 (gcc 3.3.2-r5). Remember not to launch util.exe from c:\ - before writing 'util [ENTER]' cd to some directory which isn't in your path first (as I did).

Reply 5 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Really odd
I did

mount c /tmp
c:
cd games
set path=c:\util
util

what are your compiler options ? do you happen to use -fomit-framepointer or some string optimilisations.

I'm using
g++ (GCC) 3.3.3 (Debian 20040401)

Water flows down the stream
How to ask questions the smart way!