msdos/int21 CREAT special cases

Andreas Mohr andi at rhlx01.fht-esslingen.de
Wed May 28 01:58:15 CDT 2003


On Mon, May 26, 2003 at 01:04:49PM +0200, Ferenc Wagner wrote:
> Volume label creation should fail, not create a regular file.
> Similarly for file names ending in a slash (this is actually
> needed for PKSFX Version 2.04g to unpack directory trees).
> 
>                                                 Feri.
> 
> Index: msdos/int21.c
> ===================================================================
> RCS file: /home/wine/wine/msdos/int21.c,v
> retrieving revision 1.93
> diff -u -r1.93 int21.c
> --- msdos/int21.c	19 May 2003 21:40:05 -0000	1.93
> +++ msdos/int21.c	26 May 2003 10:48:21 -0000
> @@ -474,8 +474,18 @@
>  }
>  static BOOL INT21_CreateFile( CONTEXT86 *context )
>  {
> -    SET_AX( context, _lcreat16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
> -                                                   context->Edx ), CX_reg(context) ) );
> +    LPCSTR path=CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
> +
> +    if (CX_reg(context) == 0x0008) {
> +        SetLastError( ERROR_ACCESS_DENIED );
> +        return TRUE;
> +    }
> +    if (path[strlen(path)-1] == '/')
> +    {
> +        SetLastError( ERROR_FILE_NOT_FOUND );
> +        return TRUE;
> +    }
> +    SET_AX( context, _lcreat16( path, CX_reg(context) ) );
>      return (AX_reg(context) == (WORD)HFILE_ERROR16);
>  }
Hmm, and is there a reason to not do it in _lcreat16() instead?
Or is _lcreat16() really "clever" enough to handle volume labels
"properly" if called directly?
Somehow I doubt it... ;)
Or in fact you could walk further up the chain and maybe find that even
_lcreat() should be the function to have that check instead...
(or, for that matter, even CreateFileA and thus CreateFileW...)

So my rough guess is that this should probably be prevented in CreateFileW
instead even.

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
Tel. +49 7159 800604                http://mohr.de.tt



More information about the wine-devel mailing list