Wed May 30 01:04:00 GMT 2018
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 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
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:
I also left your assertion in the code for now as an additional patch
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.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Cygwin