Mask off unsupported attributes in _lcreat (bug reported by Andreas Mohr).

Moved _lcreat16_uniq to int21.c
This commit is contained in:
Alexandre Julliard 1999-04-03 13:54:51 +00:00
parent 734247b529
commit d5240f13db
3 changed files with 16 additions and 22 deletions

View File

@ -1196,32 +1196,21 @@ UINT16 WINAPI _lread16( HFILE16 hFile, LPVOID buffer, UINT16 count )
*/
HFILE16 WINAPI _lcreat16( LPCSTR path, INT16 attr )
{
TRACE(file, "%s %02x\n", path, attr );
return FILE_AllocDosHandle( _lcreat( path, attr ) );
}
/***********************************************************************
* _lcreat32 (KERNEL32.593)
* _lcreat (KERNEL32.593)
*/
HFILE WINAPI _lcreat( LPCSTR path, INT attr )
{
/* Mask off all flags not explicitly allowed by the doc */
attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
TRACE(file, "%s %02x\n", path, attr );
return CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, attr, -1 );
}
/***********************************************************************
* _lcreat16_uniq (Not a Windows API)
*/
HFILE16 _lcreat16_uniq( LPCSTR path, INT attr )
{
TRACE(file, "%s %02x\n", path, attr );
return FILE_AllocDosHandle( CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_NEW, attr, -1 ));
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, attr, -1 );
}

View File

@ -48,7 +48,6 @@ extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
extern HFILE16 FILE_AllocDosHandle( HANDLE handle );
extern BOOL FILE_InitProcessDosHandles( void );
extern HANDLE FILE_GetHandle( HFILE16 hfile );
extern HFILE16 _lcreat16_uniq( LPCSTR path, INT attr );
/* files/directory.c */
extern int DIR_Init(void);

View File

@ -429,6 +429,14 @@ static BOOL INT21_CreateFile( CONTEXT *context )
return (AX_reg(context) == (WORD)HFILE_ERROR16);
}
static HFILE16 _lcreat16_uniq( LPCSTR path, INT attr )
{
/* Mask off all flags not explicitly allowed by the doc */
attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
return FILE_AllocDosHandle( CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_NEW, attr, -1 ));
}
static void OpenExistingFile( CONTEXT *context )
{
@ -1524,9 +1532,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
TRACE(int21,"CREAT flag 0x%02x %s\n",CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ), CX_reg(context) );
bSetDOSExtendedError = (AX_reg(context) == (WORD)HFILE_ERROR16);
bSetDOSExtendedError = INT21_CreateFile( context );
break;
case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
@ -1973,8 +1979,8 @@ void WINAPI DOS3Call( CONTEXT *context )
TRACE(int21,"CREATE NEW FILE 0x%02x for %s\n", CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = ((AX_reg(context) =
_lcreat16_uniq( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)), 0 ))
== (WORD)HFILE_ERROR16);
_lcreat16_uniq( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
CX_reg(context) )) == (WORD)HFILE_ERROR16);
break;
case 0x5d: /* NETWORK */