From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Cc: Ken Harris <Ken.Harris@mathworks.com>
Subject: Re: winsup\cygwin\path.cc issues
Date: Wed, 30 May 2018 01:04:00 -0000 [thread overview]
Message-ID: <20180529163141.GI3501@calimero.vinschen.de> (raw)
In-Reply-To: <DM2PR0501MB1358382033C52CD40E92634F8A860@DM2PR0501MB1358.namprd05.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 2546 bytes --]
Hi Ken,
On May 4 01:23, Ken Harris wrote:
> Hi Marco: Sorry for not replying to the original exchange we had. I
> wasn't subscribed to the list but now I am so it won't happen again
> (so I'm quoting our exchange below).
>
> I installed and built cygwin1.dll with an added assert
> in path.cc to identify when the buffer underrun
> condition I originally described occurs:
>
> $ diff -b
> ./cygwin-2.10.0-1.src/newlib-cygwin/winsup/cygwin/path.cc.ORIG
> ./cygwin-2.10.0-1.src/newlib-cygwin/winsup/cygwin/path.cc 2803c2803 <
> ; ---
> > assert(p >= path);
>
> Thus, a simple:
>
> cat '\A../../../B'
>
> will result in the assert firing:
>
> kharris@ah-kharris /usr/src $ cat '\A../../../B' assertion "p >= path"
> failed: file "../../.././winsup/cygwin/path.cc", line 2803, function:
> int symlink_info::check(char*, const suffix_info*, fs_info&,
> path_conv_handle&) Aborted (core dumped)
>
> Attached is a patch (in addition to the added assert) with what I
> *think* might really fix the problem. This was where the expected
> backslash got squashed which allowed symlink_info::check() to go
> "negative" with its 'p' pointer and look for a backslash in someone
> else's memory.
Thanks for your preliminary work, but as far as I can see this isn't the
entire solution. The same problem occurs if your CWD is the root of a
drive, e.g., C:\, and you call cat A../../../B. Even simpler, try `cat
'C:\A../../../B''
The reason is that the code in normalize_win32_path never actually
ignores drive prefixes. There's an implicit (and oh so wrong) assumption
that any path starts with a slash or backslash one way or the other.
It's pretty weird that it took so long to find this blatant problem.
I applied a patch which hopefully fixes this problem in all code paths:
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=35998fc2fa6c
I also left your assertion in the code for now as an additional patch
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=7d00a5e320db
just to be sure, but I will take this out again before a release.
I uploaded new developer snapshots to https://cygwin.com/snapshots/
containing the above patches. Please give them a try.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-05-29 16:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-04 1:23 Ken Harris
2018-05-30 1:04 ` Corinna Vinschen [this message]
2018-05-30 11:56 ` Ken Harris
-- strict thread matches above, loose matches on Subject: below --
2018-05-02 13:49 Ken Harris
2018-05-02 17:15 ` Marco Atzeri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180529163141.GI3501@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=Ken.Harris@mathworks.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).