From: Ken Harris <Ken.Harris@mathworks.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: winsup\cygwin\path.cc issues
Date: Wed, 30 May 2018 11:56:00 -0000 [thread overview]
Message-ID: <BN6PR05MB344488E0136690B749EB18038A6C0@BN6PR05MB3444.namprd05.prod.outlook.com> (raw)
In-Reply-To: <20180529163141.GI3501@calimero.vinschen.de>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 3290 bytes --]
Thank you so much, Corinna: So far - it looks great. I'll roll your patch into our MSYS2 build which will exercise it about as widely as we possibly can. If I see anything amiss, I'll track it down, and if I can repro in Cygwin alone, I'll report back.
Again, Thanks!
-Ken
-----Original Message-----
From: Corinna Vinschen [mailto:corinna-cygwin@cygwin.com]
Sent: Tuesday, May 29, 2018 12:32 PM
To: cygwin@cygwin.com
Cc: Ken Harris <Ken.Harris@mathworks.com>
Subject: Re: winsup\cygwin\path.cc issues
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
\x03BKCB\x1cØ\x19[H\x1c\^[Ü\x1cÎ\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÜ\x1cØ\x19[\Ë\x1d^[[\x03BTN\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ\KÃB^[ØÝ[Y[\x18]\x1a[Û\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ^[ØÜË\x1d^[[\x03B[ÝXØÜXH\x1a[Î\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÛ[\vÈÝ[ÝXØÜXK\Ú[\^[\x19CBB
next prev parent reply other threads:[~2018-05-30 1:04 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
2018-05-30 11:56 ` Ken Harris [this message]
-- 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=BN6PR05MB344488E0136690B749EB18038A6C0@BN6PR05MB3444.namprd05.prod.outlook.com \
--to=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).