From d5240f13db47cd74d6be97cebe5733df5756a0be Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 3 Apr 1999 13:54:51 +0000 Subject: [PATCH] Mask off unsupported attributes in _lcreat (bug reported by Andreas Mohr). Moved _lcreat16_uniq to int21.c --- files/file.c | 21 +++++---------------- include/file.h | 1 - msdos/int21.c | 16 +++++++++++----- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/files/file.c b/files/file.c index 8936215c967..f9851dd6c6c 100644 --- a/files/file.c +++ b/files/file.c @@ -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 ); } diff --git a/include/file.h b/include/file.h index 41896653717..10d786d4002 100644 --- a/include/file.h +++ b/include/file.h @@ -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); diff --git a/msdos/int21.c b/msdos/int21.c index 31435440560..f1e756d6264 100644 --- a/msdos/int21.c +++ b/msdos/int21.c @@ -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 */