Subject: Re: bug#13553: 24.3.50; incorrect usage of IS_DIRECTORY_SEP

From: Eli Zaretskii <[email-masked]>
Date: Sat, 26 Jan 2013 13:16:50 +0200

> From: Stefan Monnier <[email-masked]>
> Date: Sat, 26 Jan 2013 05:26:04 -0500
> Cc: [email-masked]
> 
> > It is because IS_DIRECTORY_SEP is wrongly used.
> > IS_DIRECTORY_SEP only works when its argument is surely on a start
> > byte of dbcs characters.
> 
> If the file name is properly decoded (i.e. in its multibyte form), there
> can't be a 0x5c byte other than at the beginning of a char.
> 
> So this bug can only happens if you pass a unibyte filename.  IOW the
> bug is probably in the caller rather than in the file-attributes function.

No, it's not in the caller.  It's in w32.c, whose functions almost
always manipulate encoded file names (because they shadow system
APIs).

> Please show us the actual situation where this happens, since file names
> are normally always multibyte.

You call file-attributes, which encodes the file name and passes it to
'lstat'.  The implementation of 'lstat' in w32.c then looks at the
last byte of the encoded file name to see if there's a slash or
backslash there.  Boom!

I will fix that.