This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Cygwin: remove old cruft from path_conv::check
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Sat, 21 Sep 2019 17:37:02 +0000
- Subject: Re: [PATCH] Cygwin: remove old cruft from path_conv::check
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ihOSYE4NHqbdNQYtELZqUqZTsMgCBuy/12I5MzCQcdo=; b=aq+3hYnImqg6D15gJK+vx0VLtI3QXOVRBAuzDPGh7RTyUmJEGr57y16yjWnUBSOmcWTbCzY6mwiSGX0g2iAPJP8DoEO6gjuecLcJ5uB5iZnizyMOgMf7cVwQDyrw+GOMSJWQwqMWhEMTrYymwgJGyxzXJG0hYvXoX+a4x1Q45aZg9WI3PRuhl1ewobZwbzk5NaJIoxX+FgEr/BgN5ir26ydIVCp/ZI8PvMoa4KFvhtzfsKm+7YmcpOZZSAwB8iNlNg97KBWeGjXi38c6HDtLILQ56dh9J6TUmOmfPygvLK9VvOT2rSPETAGxrw9wEpd6u7t4Qp5tOXKZPss8T8290Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0S2rdQD0jgORsXl2F1bujclXyZTxWdm8EsEAjwGGYUDyB+B/t+PAHp7g3Ak0QxBIkaJrCKUQlRijpW1l4tHSLjJzF1QSnGijXUuWgdpicW9kq6gyCkzrAy2eDg3YRflIXDv/W9ACN9znbkz9QUQ1Vu+XN0NyjoiQgFjqZTXQ1Wo2zjy7jp3yd0FxKE8tBHQCWXWjg1XwZqm8hUTN19ggQ3t5bB5Dt+tgMXRrtgCtMorObUyxO7edjY4eOzd+hahxf1fDVpIFOlTh9zmvzy1srziVxmvWd2tSl+TpVr5o2dxGWPDk3oU/fCaNIEY+MNEeTAnTFSCQdUtP9ggWBpisQ==
- References: <20190921173347.1527-1-kbrown@cornell.edu>
On 9/21/2019 1:34 PM, Ken Brown wrote:
> Prior to commit b0717aae, path_conv::check had the following code:
>
> if (strncmp (path, "\\\\.\\", 4))
> {
> /* Windows ignores trailing dots and spaces in the last path
> component, and ignores exactly one trailing dot in inner
> path components. */
> char *tail = NULL;
> [...]
> if (!tail || tail == path)
> /* nothing */;
> else if (tail[-1] != '\\')
> {
> *tail = '\0';
> [...]
> }
>
> Commit b0717aae0 intended to disable this code, but it inadvertently
> disabled only part of it. In particular, the declaration of the local
> tail variable was in the disabled code, but the following remained:
>
> if (!tail || tail == path)
> /* nothing */;
> else if (tail[-1] != '\\')
> {
> *tail = '\0';
> [...]
> }
>
> [A later commit removed the disabled code.]
>
> The tail variable here points into a string different from path,
> causing that string to be truncated under some circumstances. See
>
> https://cygwin.com/ml/cygwin/2019-09/msg00001.html
>
> for more details.
>
> This commit fixes the problem by removing the leftover code
> that was intended to be removed in b0717aae.
> ---
> winsup/cygwin/path.cc | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
> index c13701aa0..2fbacd881 100644
> --- a/winsup/cygwin/path.cc
> +++ b/winsup/cygwin/path.cc
> @@ -1168,19 +1168,6 @@ path_conv::check (const char *src, unsigned opt,
>
> if (dev.isfs ())
> {
> - if (strncmp (path, "\\\\.\\", 4))
> - {
> - if (!tail || tail == path)
> - /* nothing */;
> - else if (tail[-1] != '\\')
> - *tail = '\0';
> - else
> - {
> - error = ENOENT;
> - return;
> - }
> - }
> -
> /* If FS hasn't been checked already in symlink_info::check,
> do so now. */
> if (fs.inited ()|| fs.update (get_nt_native_path (), NULL))
This seems pretty straightforward to me, but I'll wait a few days before
committing it in case I'm missing something.
Ken