The invalid pathname character detection is moved from ParseDosName (dosnames.c)
to truename (newstuff.c), because TRUENAME should check these characters before passing paths on to fatfs.c & fatdir.c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1440 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
c812a96e85
commit
f7a9177b64
@ -37,33 +37,6 @@ static BYTE *dosnamesRcsId =
|
|||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,";
|
|
||||||
|
|
||||||
#define PathSep(c) ((c)=='/'||(c)=='\\')
|
|
||||||
#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z'))
|
|
||||||
#define DirChar(c) (((unsigned char)(c)) >= ' ' && \
|
|
||||||
!strchr(_DirWildNameChars+5, (c)))
|
|
||||||
#define WildChar(c) (((unsigned char)(c)) >= ' ' && \
|
|
||||||
!strchr(_DirWildNameChars+2, (c)))
|
|
||||||
#define NameChar(c) (((unsigned char)(c)) >= ' ' && \
|
|
||||||
!strchr(_DirWildNameChars, (c)))
|
|
||||||
|
|
||||||
VOID XlateLcase(BYTE * szFname, COUNT nChars);
|
|
||||||
VOID DosTrimPath(BYTE * lpszPathNamep);
|
|
||||||
|
|
||||||
/* Should be converted to a portable version after v1.0 is released. */
|
|
||||||
#if 0
|
|
||||||
VOID XlateLcase(BYTE * szFname, COUNT nChars)
|
|
||||||
{
|
|
||||||
while (nChars--)
|
|
||||||
{
|
|
||||||
if (*szFname >= 'a' && *szFname <= 'z')
|
|
||||||
*szFname -= ('a' - 'A');
|
|
||||||
++szFname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MSD durring an FindFirst search string looks like this;
|
MSD durring an FindFirst search string looks like this;
|
||||||
(*), & (.) == Current directory *.*
|
(*), & (.) == Current directory *.*
|
||||||
@ -88,8 +61,8 @@ int ParseDosName(const char *filename, BOOL bAllowWildcards)
|
|||||||
/* Now see how long a directory component we have. */
|
/* Now see how long a directory component we have. */
|
||||||
lpszLclDir = lpszLclFile = filename;
|
lpszLclDir = lpszLclFile = filename;
|
||||||
filename += 2;
|
filename += 2;
|
||||||
|
|
||||||
while (DirChar(*filename))
|
while (*filename)
|
||||||
{
|
{
|
||||||
if (*filename == '\\')
|
if (*filename == '\\')
|
||||||
lpszLclFile = filename + 1;
|
lpszLclFile = filename + 1;
|
||||||
@ -99,8 +72,7 @@ int ParseDosName(const char *filename, BOOL bAllowWildcards)
|
|||||||
|
|
||||||
/* Parse out the file name portion. */
|
/* Parse out the file name portion. */
|
||||||
filename = lpszLclFile;
|
filename = lpszLclFile;
|
||||||
while (bAllowWildcards ? WildChar(*filename) :
|
while (*filename)
|
||||||
NameChar(*filename))
|
|
||||||
++filename;
|
++filename;
|
||||||
|
|
||||||
if (filename == lpszLclFile)
|
if (filename == lpszLclFile)
|
||||||
@ -113,23 +85,6 @@ int ParseDosName(const char *filename, BOOL bAllowWildcards)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we have pointers set to the directory portion and the */
|
|
||||||
/* file portion. Now determine the existance of an extension. */
|
|
||||||
if ('.' == *filename)
|
|
||||||
{
|
|
||||||
++filename;
|
|
||||||
while (*filename)
|
|
||||||
{
|
|
||||||
if (bAllowWildcards ? WildChar(*filename) :
|
|
||||||
NameChar(*filename))
|
|
||||||
++filename;
|
|
||||||
else
|
|
||||||
return DE_FILENOTFND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (*filename)
|
|
||||||
return DE_FILENOTFND;
|
|
||||||
|
|
||||||
return nDirCnt;
|
return nDirCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,11 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
|
|||||||
#define PNE_WILDCARD 1
|
#define PNE_WILDCARD 1
|
||||||
#define PNE_DOT 2
|
#define PNE_DOT 2
|
||||||
|
|
||||||
|
STATIC const char _DirChars[] = "\"[]:|<>+=;,";
|
||||||
|
|
||||||
|
#define DirChar(c) (((unsigned char)(c)) >= ' ' && \
|
||||||
|
!strchr(_DirChars, (c)))
|
||||||
|
|
||||||
#define addChar(c) \
|
#define addChar(c) \
|
||||||
{ \
|
{ \
|
||||||
if (p >= dest + SFTMAX) PATH_ERROR; /* path too long */ \
|
if (p >= dest + SFTMAX) PATH_ERROR; /* path too long */ \
|
||||||
@ -287,6 +292,7 @@ STATIC int parse_name_ext(int i, const char FAR **src, char **cp, char *dest)
|
|||||||
default:
|
default:
|
||||||
if (i) { /* name length in limits */
|
if (i) { /* name length in limits */
|
||||||
--i;
|
--i;
|
||||||
|
if (!DirChar(c)) PATH_ERROR;
|
||||||
addChar(c);
|
addChar(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user