Commit 517c6bdb authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Name resolution, wildcarded FSEntry_File 5 & 9, and buffer overrun fixes

Make SMB_RxWords a bit bigger per static anaylsis
  https://www.riscosopen.org/forum/forums/4/topics/9503
when LONGNAMES is undefined, since NT LM 0.12 dialect is allowed at the same time as short names.

A change to name translation in LanManFS-2_60 broke all forms of nested contentious name resolution, ie. where a leafname containing a contentious character was itself in a directory containing one.
The cited problem names ('1 2/3' and '1 /s') can both be resolved at one level only, no 2nd pass is required. The resolution function walks along the elements of the path one at a time to reach the leaf (ie. no element is processed twice). A test case has been created to allow some regression testing when making future changes in this area.

When building tboxlibint
  Copy h.* <Lib$Dir>.tboxlibint.h.*
when the directory is empty FileSwitch checks the destination ending in ...\h\* which the short names translation would error with ENOWILDCARD, but the long names translation attempts to resolve it by finding the trailing '\' and appending a '*' (ie. not doing anything), this returns no results and is passed back unfaulted. The special check in fsentry_file() for ENOWILDCARD for the two ReadCatalogueInformation thus doesn't trigger, and an attempt to FileGetAttribs() is made on the still wildcarded path. This is rejected by the server when in SMB_GetAttribsX2() does a TRANSACT2_QUERYPATHINFORMATION, which expects a non wildcarded object (on Windows servers at least), propagating an error back up to the user.
This stopped a ROM build from completing the exports phase via LanManFS on a Windows share.

Const-ify a few things.

Changed files
  Xlate.c: Revert change from revision 1.21, return ENOWILDCARD when appropriate.
  SMC.c: Increase MAX_WCT buffer size to 17.
  UK/CmdHelp: Add some missing chevrons round the command syntax for required parameters.
  test/Contentious: Test case for nested contentious character resolution code.

Version 2.61. Tagged as 'LanManFS-2_61'
parent 7587ab10
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
No preview for this file type
/* (2.60) /* (2.61)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 2.60 #define Module_MajorVersion_CMHG 2.61
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 23 Jan 2017 #define Module_Date_CMHG 03 Jan 2018
#define Module_MajorVersion "2.60" #define Module_MajorVersion "2.61"
#define Module_Version 260 #define Module_Version 261
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "23 Jan 2017" #define Module_Date "03 Jan 2018"
#define Module_ApplicationDate "23-Jan-17" #define Module_ApplicationDate "03-Jan-18"
#define Module_ComponentName "LanManFS" #define Module_ComponentName "LanManFS"
#define Module_ComponentPath "castle/RiscOS/Sources/Networking/Omni/Protocols/LanManFS" #define Module_ComponentPath "castle/RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.60" #define Module_FullVersion "2.61"
#define Module_HelpVersion "2.60 (23 Jan 2017)" #define Module_HelpVersion "2.61 (03 Jan 2018)"
#define Module_LibraryVersionInfo "2:60" #define Module_LibraryVersionInfo "2:61"
...@@ -139,12 +139,12 @@ typedef struct ...@@ -139,12 +139,12 @@ typedef struct
/* Maximum number of word params - 14 is used by Transact */ /* Maximum number of word params - 14 is used by Transact */
#ifdef LONGNAMES #ifdef LONGNAMES
/* Transact2 (LONGNAMES build only) requires 14 plus setup words /* Transact2 (LONGNAMES build only) requires extra setup words.
* The NT LM 0.12 negprot response requires 17. * The NT LM 0.12 negprot response requires 17.
*/ */
#define MAX_WCT (17+(MAX_SETUPWORDS)+1) #define MAX_WCT (17+(MAX_SETUPWORDS)+1)
#else #else
#define MAX_WCT 14 #define MAX_WCT 17
#endif #endif
/* Max number of significant characters in a shared drive /* Max number of significant characters in a shared drive
...@@ -445,11 +445,11 @@ static BUFCHAIN AddUnicodeStringToChain ( BUFCHAIN pB, char *str ) ...@@ -445,11 +445,11 @@ static BUFCHAIN AddUnicodeStringToChain ( BUFCHAIN pB, char *str )
/* --------------------- */ /* --------------------- */
static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, char *ptr ) static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, const char *ptr )
{ {
BYTE hdrblk[4]; BYTE hdrblk[4];
pB = AddChain ( pB, ptr, strlen(ptr)+1 ); pB = AddChain ( pB, (void *)ptr, strlen(ptr)+1 );
if ( pB == NULL ) return NULL; if ( pB == NULL ) return NULL;
...@@ -820,7 +820,7 @@ static err_t SMB_WriteRaw ( hSHARE hS, int fid, uint offset, ...@@ -820,7 +820,7 @@ static err_t SMB_WriteRaw ( hSHARE hS, int fid, uint offset,
* call this function to find out which protocol was accepted. The * call this function to find out which protocol was accepted. The
* offsets within the array of each string are vital to SMB_Negotiate. * offsets within the array of each string are vital to SMB_Negotiate.
*/ */
static char *dialects[] = { static const char *dialects[] = {
"PC NETWORK PROGRAM 1.0", "PC NETWORK PROGRAM 1.0",
"DOS LM1.2X002", "DOS LM1.2X002",
"LM1.2X002", "LM1.2X002",
...@@ -830,7 +830,7 @@ static char *dialects[] = { ...@@ -830,7 +830,7 @@ static char *dialects[] = {
#define DIALECT_BASIC 0 #define DIALECT_BASIC 0
#define DIALECT_LM12X002 1 #define DIALECT_LM12X002 1
#define DIALECT_NT 3 #define DIALECT_NT 3
static char *SMB_Dialect(unsigned int num) static const char *SMB_Dialect(unsigned int num)
{ {
if (num <= MAX_DIALECT) return dialects[num]; if (num <= MAX_DIALECT) return dialects[num];
return ""; return "";
......
...@@ -840,12 +840,6 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level ) ...@@ -840,12 +840,6 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level )
debug1("Xlt_NameROtoDOSX2 initiates a dir search of `%s'\n", debug1("Xlt_NameROtoDOSX2 initiates a dir search of `%s'\n",
private.dstcpybuf); private.dstcpybuf);
#if 0
// if I'm not mistaken, the previous translate gets all the contentious chars
// so if the result contains translated chars that would then be contentious
// in riscos, they get retranslated to give incorrect result.
// e.g. riscos '.1 /s' becomes 'A:\1 .s' as expected.
// Second pass takes it to 'A:\1 \s' which is incorrect.
if (level == 0) if (level == 0)
for (inptr = private.dstcpybuf + 2 + level; inptr != private.dstcpy; ++inptr) { for (inptr = private.dstcpybuf + 2 + level; inptr != private.dstcpy; ++inptr) {
if (Xlt_ContentiousCharCheck(*inptr, *inptr)) { if (Xlt_ContentiousCharCheck(*inptr, *inptr)) {
...@@ -895,7 +889,7 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level ) ...@@ -895,7 +889,7 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level )
inptr = private.dstcpybuf + len; inptr = private.dstcpybuf + len;
} }
} }
#endif
debug1("Xlt_NameROtoDOSX2 initiates a dir search of `%s' (post-mangle)\n", debug1("Xlt_NameROtoDOSX2 initiates a dir search of `%s' (post-mangle)\n",
private.dstcpybuf); private.dstcpybuf);
...@@ -944,6 +938,7 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level ) ...@@ -944,6 +938,7 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level )
*/ */
static err_t Xlt_NameROtoDOSX2 ( char *dst, char *src ) static err_t Xlt_NameROtoDOSX2 ( char *dst, char *src )
{ {
if (strchr(src, '*') != NULL) return ENOWILDCARD; /* As per nameROtoDOS() */
return Xlt_NameROtoDOSX2_sub(dst, src, 0); return Xlt_NameROtoDOSX2_sub(dst, src, 0);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment