This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Cygwin: rmdir: fail if last component is a symlink, as on Linux


On 9/22/2019 1:18 PM, Ken Brown wrote:
[...]
> @@ -354,6 +353,25 @@ rmdir (const char *dir)
>   
>     __try
>       {
> +      if (!*dir)
> +	{
> +	  set_errno (ENOENT);
> +	  __leave;
> +	}
> +
> +      /* Following Linux, do not resolve the last component of DIR if
> +	 it is a symlink, even if DIR has a trailing slash.  Achieve
> +	 this by stripping trailing slashes or backslashes.  */
> +      if (isdirsep (dir[strlen (dir) - 1]))
> +	{
> +	  /* This converts // to /, but since both give ENOTEMPTY,
> +	     we're okay.  */
> +	  char *buf;
> +	  char *p = stpcpy (buf = tp.c_get (), dir) - 1;

I forgot to declare tp.  v2 is on the way.

Ken


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]