mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
build.c: fix strcpy() with overlapping arguments.
git-svn-id: https://svn.eduke32.com/eduke32@3750 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3833654535
commit
5e1ec28798
1 changed files with 21 additions and 22 deletions
|
@ -220,6 +220,12 @@ static void correct_ornamented_sprite(int32_t i, int32_t hitw);
|
||||||
|
|
||||||
static int32_t getfilenames(const char *path, const char *kind);
|
static int32_t getfilenames(const char *path, const char *kind);
|
||||||
|
|
||||||
|
// Get basename of BUILD file name (forward slashes as directory separators).
|
||||||
|
static const char *getbasefn(const char *fn)
|
||||||
|
{
|
||||||
|
const char *slash = Bstrrchr(fn, '/');
|
||||||
|
return slash ? slash+1 : fn;
|
||||||
|
}
|
||||||
|
|
||||||
void clearkeys(void)
|
void clearkeys(void)
|
||||||
{
|
{
|
||||||
|
@ -7682,9 +7688,16 @@ CANCEL:
|
||||||
|
|
||||||
bad = 0;
|
bad = 0;
|
||||||
|
|
||||||
|
// Back up full name.
|
||||||
Bstrcpy(selectedboardfilename, boardfilename);
|
Bstrcpy(selectedboardfilename, boardfilename);
|
||||||
if (Bstrrchr(boardfilename, '/'))
|
|
||||||
Bstrcpy(boardfilename, Bstrrchr(boardfilename, '/')+1);
|
// Get base name.
|
||||||
|
{
|
||||||
|
const char *basefn = getbasefn(boardfilename);
|
||||||
|
|
||||||
|
if (basefn != boardfilename)
|
||||||
|
Bmemmove(boardfilename, basefn, Bstrlen(basefn)+1);
|
||||||
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (boardfilename[i] != 0 && i < 64)
|
while (boardfilename[i] != 0 && i < 64)
|
||||||
|
@ -7739,6 +7752,7 @@ CANCEL:
|
||||||
|
|
||||||
Bstrcpy(&boardfilename[i], ".map");
|
Bstrcpy(&boardfilename[i], ".map");
|
||||||
|
|
||||||
|
// Update full name with new basename.
|
||||||
slash = Bstrrchr(selectedboardfilename,'/');
|
slash = Bstrrchr(selectedboardfilename,'/');
|
||||||
Bstrcpy(slash ? slash+1 : selectedboardfilename, boardfilename);
|
Bstrcpy(slash ? slash+1 : selectedboardfilename, boardfilename);
|
||||||
|
|
||||||
|
@ -7970,25 +7984,15 @@ static void SaveBoardAndPrintMessage(const char *fn)
|
||||||
// get the file name of the file that would be written if SaveBoard(fn, 0) was called
|
// get the file name of the file that would be written if SaveBoard(fn, 0) was called
|
||||||
const char *GetSaveBoardFilename(const char *fn)
|
const char *GetSaveBoardFilename(const char *fn)
|
||||||
{
|
{
|
||||||
const char *f;
|
|
||||||
|
|
||||||
if (!fn)
|
if (!fn)
|
||||||
fn = boardfilename;
|
fn = boardfilename;
|
||||||
|
|
||||||
if (pathsearchmode)
|
if (pathsearchmode)
|
||||||
f = fn;
|
return fn;
|
||||||
else
|
|
||||||
{
|
|
||||||
// virtual filesystem mode can't save to directories so drop the file into
|
|
||||||
// the current directory
|
|
||||||
f = Bstrrchr(fn, '/');
|
|
||||||
if (!f)
|
|
||||||
f = fn;
|
|
||||||
else
|
|
||||||
f++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return f;
|
// virtual filesystem mode can't save to directories so drop the file into
|
||||||
|
// the current directory
|
||||||
|
return getbasefn(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// flags: 1:no ExtSaveMap (backup.map) and no taglabels saving
|
// flags: 1:no ExtSaveMap (backup.map) and no taglabels saving
|
||||||
|
@ -9201,12 +9205,7 @@ static char g_oldpath[BMAX_PATH];
|
||||||
static void menuselect_try_findlast(void)
|
static void menuselect_try_findlast(void)
|
||||||
{
|
{
|
||||||
// PK 20080103: start with last selected map
|
// PK 20080103: start with last selected map
|
||||||
const char *boardbasename = Bstrrchr(boardfilename, '/');
|
const char *boardbasename = getbasefn(boardfilename);
|
||||||
|
|
||||||
if (!boardbasename)
|
|
||||||
boardbasename=boardfilename;
|
|
||||||
else
|
|
||||||
boardbasename++;
|
|
||||||
|
|
||||||
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
||||||
if (!Bstrcmp(findfileshigh->name, boardbasename))
|
if (!Bstrcmp(findfileshigh->name, boardbasename))
|
||||||
|
|
Loading…
Reference in a new issue