Pull in forgotten native symlink patch

This commit is contained in:
Corinna Vinschen 2014-07-16 08:01:00 +00:00
parent 2d1c36beaf
commit 92f2522b66
7 changed files with 283 additions and 237 deletions

View File

@ -203,6 +203,28 @@
* winf.cc (linebuf::fromargv): Temporarily revert patch from 2014-01-24.
2014-04-18 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h (TP_NUM_C_BUFS): Raise to 50 to allow SYMLOOP_MAX recursions
path_conv <-> normalize_posix_path, plus a bit of buffer.
(TP_NUM_W_BUFS): Ditto.
(class san): Change type of _c_cnt and _w_cnt to unsigned.
* path.cc (normalize_posix_path): Guard recursion into path_conv
against tmp_pathbuf overflow. Generate normalized path in call to
path_conv. If the path is valid, replace dst with the normalized_path
from path_conv call. Add comment to explain why we're doing this.
* tls_pbuf.cc (tls_pathbuf::destroy): Only free buffers until the
first buffer pointer is NULL.
(tmp_pathbuf::c_get): Simplify error message.
(tmp_pathbuf::w_get): Ditto.
* tls_pbuf.h (class tmp_pathbuf): Change type of c_buf_old and w_buf_old
to unsigned.
(tmp_pathbuf::check_usage): New inline method to check if we have
enough tmp_pathbuf buffers left to call a function using tmp_pathbuf
buffers.
* tlsoffsets.h: Regenerate.
* tlsoffsets64.h: Regenerate.
2014-04-16 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_setsockopt): Ignore IPV6_TCLASS the same way as IP_TOS.

View File

@ -1,7 +1,7 @@
/* cygtls.h
Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
Red Hat, Inc.
Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
@ -32,8 +32,8 @@ details. */
#include "cygthread.h"
#define TP_NUM_C_BUFS 10
#define TP_NUM_W_BUFS 10
#define TP_NUM_C_BUFS 50
#define TP_NUM_W_BUFS 50
#ifdef CYGTLS_HANDLE
#include "thread.h"
@ -297,8 +297,8 @@ class san
san *_clemente;
jmp_buf _context;
int _errno;
int _c_cnt;
int _w_cnt;
unsigned _c_cnt;
unsigned _w_cnt;
public:
int setup (int myerrno = 0) __attribute__ ((always_inline))
{

View File

@ -311,9 +311,31 @@ normalize_posix_path (const char *src, char *dst, char *&tail)
{
*tail = 0;
debug_printf ("checking %s before '..'", dst);
path_conv head (dst);
/* In conjunction with native and NFS symlinks,
this call can result in a recursion which eats
up our tmp_pathbuf buffers. This in turn results
in a api_fatal call. To avoid that, we're
checking our remaining buffers and return an
error code instead. Note that this only happens
if the path contains 15 or more relative native/NFS
symlinks with a ".." in the target path. */
tmp_pathbuf tp;
if (!tp.check_usage (4, 3))
return ELOOP;
path_conv head (dst, PC_SYM_FOLLOW | PC_POSIX);
if (!head.isdir())
return ENOENT;
/* At this point, dst is a normalized path. If the
normalized path created by path_conv does not
match the normalized path we're just testing, then
the path in dst contains native symlinks. If we
just plunge along, removing the previous path
component, we may end up removing a symlink from
the path and the resulting path will be invalid.
So we replace dst with what we found in head
instead. All the work replacing symlinks has been
done in that path anyway, so why repeat it? */
tail = stpcpy (dst, head.normalized_path);
}
check_parent = false;
}
@ -3912,8 +3934,7 @@ fcwd_access_t::SetVersionFromPointer (PBYTE buf_p, bool is_buffer)
This code has been tested on Vista 32/64 bit, Server 2008 32/64 bit,
Windows 7 32/64 bit, Server 2008 R2 (which is only 64 bit anyway),
and W8CP 32/64 bit. There's some hope this will still work for
Windows 8 RTM... */
Windows 8 32/64 bit, Windows 8.1 32/64 bit, and Server 2012 R2. */
#ifdef __x86_64__

View File

@ -1,6 +1,6 @@
/* tls_pbuf.cc
Copyright 2008, 2010 Red Hat, Inc.
Copyright 2008, 2010, 2014 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
@ -16,12 +16,10 @@ details. */
void
tls_pathbuf::destroy ()
{
for (int i = 0; i < TP_NUM_C_BUFS; ++i)
if (c_buf[i])
free (c_buf[i]);
for (int i = 0; i < TP_NUM_W_BUFS; ++i)
if (w_buf[i])
free (w_buf[i]);
for (unsigned i = 0; i < TP_NUM_C_BUFS && c_buf[i]; ++i)
free (c_buf[i]);
for (unsigned i = 0; i < TP_NUM_W_BUFS && w_buf[i]; ++i)
free (w_buf[i]);
}
tmp_pathbuf::tmp_pathbuf ()
@ -39,7 +37,7 @@ char *
tmp_pathbuf::c_get ()
{
if (tls_pbuf.c_cnt >= TP_NUM_C_BUFS)
api_fatal ("Internal error: TP_NUM_C_BUFS too small: %u > %u", tls_pbuf.c_cnt, TP_NUM_C_BUFS);
api_fatal ("Internal error: TP_NUM_C_BUFS too small: %u", TP_NUM_C_BUFS);
if (!tls_pbuf.c_buf[tls_pbuf.c_cnt]
&& !(tls_pbuf.c_buf[tls_pbuf.c_cnt] = (char *) malloc (NT_MAX_PATH)))
api_fatal ("Internal error: Out of memory for new path buf.");
@ -50,7 +48,7 @@ PWCHAR
tmp_pathbuf::w_get ()
{
if (tls_pbuf.w_cnt >= TP_NUM_W_BUFS)
api_fatal ("Internal error: TP_NUM_W_BUFS too small %d >= %d.", tls_pbuf.w_cnt, TP_NUM_W_BUFS);
api_fatal ("Internal error: TP_NUM_W_BUFS too small: %u.", TP_NUM_W_BUFS);
if (!tls_pbuf.w_buf[tls_pbuf.w_cnt]
&& !(tls_pbuf.w_buf[tls_pbuf.w_cnt]
= (PWCHAR) malloc (NT_MAX_PATH * sizeof (WCHAR))))

View File

@ -1,6 +1,6 @@
/* tls_pbuf.h
Copyright 2008 Red Hat, Inc.
Copyright 2008, 2014 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
@ -8,12 +8,17 @@ details. */
class tmp_pathbuf
{
int c_buf_old;
int w_buf_old;
unsigned c_buf_old;
unsigned w_buf_old;
public:
tmp_pathbuf ();
~tmp_pathbuf ();
inline bool check_usage (unsigned c_need, unsigned w_need)
{
return c_need + c_buf_old < TP_NUM_C_BUFS
&& w_need + w_buf_old < TP_NUM_W_BUFS;
}
char *c_get (); /* Create temporary TLS path buf of size NT_MAX_PATH. */
PWCHAR w_get (); /* Create temporary TLS path buf of size 2 * NT_MAX_PATH. */
inline char *t_get () { return (char *) w_get (); }

View File

@ -3,115 +3,115 @@
//; $tls::start_offset = -12700;
//; $tls::locals = -12700;
//; $tls::plocals = 0;
//; $tls::local_clib = -11260;
//; $tls::plocal_clib = 1440;
//; $tls::__dontuse = -11260;
//; $tls::p__dontuse = 1440;
//; $tls::func = -10172;
//; $tls::pfunc = 2528;
//; $tls::saved_errno = -10168;
//; $tls::psaved_errno = 2532;
//; $tls::sa_flags = -10164;
//; $tls::psa_flags = 2536;
//; $tls::oldmask = -10160;
//; $tls::poldmask = 2540;
//; $tls::deltamask = -10156;
//; $tls::pdeltamask = 2544;
//; $tls::errno_addr = -10152;
//; $tls::perrno_addr = 2548;
//; $tls::sigmask = -10148;
//; $tls::psigmask = 2552;
//; $tls::sigwait_mask = -10144;
//; $tls::psigwait_mask = 2556;
//; $tls::sigwait_info = -10140;
//; $tls::psigwait_info = 2560;
//; $tls::signal_arrived = -10136;
//; $tls::psignal_arrived = 2564;
//; $tls::will_wait_for_signal = -10132;
//; $tls::pwill_wait_for_signal = 2568;
//; $tls::thread_context = -10128;
//; $tls::pthread_context = 2572;
//; $tls::thread_id = -9916;
//; $tls::pthread_id = 2784;
//; $tls::infodata = -9912;
//; $tls::pinfodata = 2788;
//; $tls::tid = -9764;
//; $tls::ptid = 2936;
//; $tls::_ctinfo = -9760;
//; $tls::p_ctinfo = 2940;
//; $tls::andreas = -9756;
//; $tls::pandreas = 2944;
//; $tls::wq = -9752;
//; $tls::pwq = 2948;
//; $tls::sig = -9724;
//; $tls::psig = 2976;
//; $tls::incyg = -9720;
//; $tls::pincyg = 2980;
//; $tls::spinning = -9716;
//; $tls::pspinning = 2984;
//; $tls::stacklock = -9712;
//; $tls::pstacklock = 2988;
//; $tls::stackptr = -9708;
//; $tls::pstackptr = 2992;
//; $tls::stack = -9704;
//; $tls::pstack = 2996;
//; $tls::initialized = -8680;
//; $tls::pinitialized = 4020;
//; $tls::local_clib = -10940;
//; $tls::plocal_clib = 1760;
//; $tls::__dontuse = -10940;
//; $tls::p__dontuse = 1760;
//; $tls::func = -9852;
//; $tls::pfunc = 2848;
//; $tls::saved_errno = -9848;
//; $tls::psaved_errno = 2852;
//; $tls::sa_flags = -9844;
//; $tls::psa_flags = 2856;
//; $tls::oldmask = -9840;
//; $tls::poldmask = 2860;
//; $tls::deltamask = -9836;
//; $tls::pdeltamask = 2864;
//; $tls::errno_addr = -9832;
//; $tls::perrno_addr = 2868;
//; $tls::sigmask = -9828;
//; $tls::psigmask = 2872;
//; $tls::sigwait_mask = -9824;
//; $tls::psigwait_mask = 2876;
//; $tls::sigwait_info = -9820;
//; $tls::psigwait_info = 2880;
//; $tls::signal_arrived = -9816;
//; $tls::psignal_arrived = 2884;
//; $tls::will_wait_for_signal = -9812;
//; $tls::pwill_wait_for_signal = 2888;
//; $tls::thread_context = -9808;
//; $tls::pthread_context = 2892;
//; $tls::thread_id = -9596;
//; $tls::pthread_id = 3104;
//; $tls::infodata = -9592;
//; $tls::pinfodata = 3108;
//; $tls::tid = -9444;
//; $tls::ptid = 3256;
//; $tls::_ctinfo = -9440;
//; $tls::p_ctinfo = 3260;
//; $tls::andreas = -9436;
//; $tls::pandreas = 3264;
//; $tls::wq = -9432;
//; $tls::pwq = 3268;
//; $tls::sig = -9404;
//; $tls::psig = 3296;
//; $tls::incyg = -9400;
//; $tls::pincyg = 3300;
//; $tls::spinning = -9396;
//; $tls::pspinning = 3304;
//; $tls::stacklock = -9392;
//; $tls::pstacklock = 3308;
//; $tls::stackptr = -9388;
//; $tls::pstackptr = 3312;
//; $tls::stack = -9384;
//; $tls::pstack = 3316;
//; $tls::initialized = -8360;
//; $tls::pinitialized = 4340;
//; __DATA__
#define tls_locals (-12700)
#define tls_plocals (0)
#define tls_local_clib (-11260)
#define tls_plocal_clib (1440)
#define tls___dontuse (-11260)
#define tls_p__dontuse (1440)
#define tls_func (-10172)
#define tls_pfunc (2528)
#define tls_saved_errno (-10168)
#define tls_psaved_errno (2532)
#define tls_sa_flags (-10164)
#define tls_psa_flags (2536)
#define tls_oldmask (-10160)
#define tls_poldmask (2540)
#define tls_deltamask (-10156)
#define tls_pdeltamask (2544)
#define tls_errno_addr (-10152)
#define tls_perrno_addr (2548)
#define tls_sigmask (-10148)
#define tls_psigmask (2552)
#define tls_sigwait_mask (-10144)
#define tls_psigwait_mask (2556)
#define tls_sigwait_info (-10140)
#define tls_psigwait_info (2560)
#define tls_signal_arrived (-10136)
#define tls_psignal_arrived (2564)
#define tls_will_wait_for_signal (-10132)
#define tls_pwill_wait_for_signal (2568)
#define tls_thread_context (-10128)
#define tls_pthread_context (2572)
#define tls_thread_id (-9916)
#define tls_pthread_id (2784)
#define tls_infodata (-9912)
#define tls_pinfodata (2788)
#define tls_tid (-9764)
#define tls_ptid (2936)
#define tls__ctinfo (-9760)
#define tls_p_ctinfo (2940)
#define tls_andreas (-9756)
#define tls_pandreas (2944)
#define tls_wq (-9752)
#define tls_pwq (2948)
#define tls_sig (-9724)
#define tls_psig (2976)
#define tls_incyg (-9720)
#define tls_pincyg (2980)
#define tls_spinning (-9716)
#define tls_pspinning (2984)
#define tls_stacklock (-9712)
#define tls_pstacklock (2988)
#define tls_stackptr (-9708)
#define tls_pstackptr (2992)
#define tls_stack (-9704)
#define tls_pstack (2996)
#define tls_initialized (-8680)
#define tls_pinitialized (4020)
#define tls_local_clib (-10940)
#define tls_plocal_clib (1760)
#define tls___dontuse (-10940)
#define tls_p__dontuse (1760)
#define tls_func (-9852)
#define tls_pfunc (2848)
#define tls_saved_errno (-9848)
#define tls_psaved_errno (2852)
#define tls_sa_flags (-9844)
#define tls_psa_flags (2856)
#define tls_oldmask (-9840)
#define tls_poldmask (2860)
#define tls_deltamask (-9836)
#define tls_pdeltamask (2864)
#define tls_errno_addr (-9832)
#define tls_perrno_addr (2868)
#define tls_sigmask (-9828)
#define tls_psigmask (2872)
#define tls_sigwait_mask (-9824)
#define tls_psigwait_mask (2876)
#define tls_sigwait_info (-9820)
#define tls_psigwait_info (2880)
#define tls_signal_arrived (-9816)
#define tls_psignal_arrived (2884)
#define tls_will_wait_for_signal (-9812)
#define tls_pwill_wait_for_signal (2888)
#define tls_thread_context (-9808)
#define tls_pthread_context (2892)
#define tls_thread_id (-9596)
#define tls_pthread_id (3104)
#define tls_infodata (-9592)
#define tls_pinfodata (3108)
#define tls_tid (-9444)
#define tls_ptid (3256)
#define tls__ctinfo (-9440)
#define tls_p_ctinfo (3260)
#define tls_andreas (-9436)
#define tls_pandreas (3264)
#define tls_wq (-9432)
#define tls_pwq (3268)
#define tls_sig (-9404)
#define tls_psig (3296)
#define tls_incyg (-9400)
#define tls_pincyg (3300)
#define tls_spinning (-9396)
#define tls_pspinning (3304)
#define tls_stacklock (-9392)
#define tls_pstacklock (3308)
#define tls_stackptr (-9388)
#define tls_pstackptr (3312)
#define tls_stack (-9384)
#define tls_pstack (3316)
#define tls_initialized (-8360)
#define tls_pinitialized (4340)

View File

@ -3,115 +3,115 @@
//; $tls::start_offset = -12800;
//; $tls::locals = -12800;
//; $tls::plocals = 0;
//; $tls::local_clib = -11200;
//; $tls::plocal_clib = 1600;
//; $tls::__dontuse = -11200;
//; $tls::p__dontuse = 1600;
//; $tls::func = -9312;
//; $tls::pfunc = 3488;
//; $tls::saved_errno = -9304;
//; $tls::psaved_errno = 3496;
//; $tls::sa_flags = -9300;
//; $tls::psa_flags = 3500;
//; $tls::oldmask = -9296;
//; $tls::poldmask = 3504;
//; $tls::deltamask = -9288;
//; $tls::pdeltamask = 3512;
//; $tls::errno_addr = -9280;
//; $tls::perrno_addr = 3520;
//; $tls::sigmask = -9272;
//; $tls::psigmask = 3528;
//; $tls::sigwait_mask = -9264;
//; $tls::psigwait_mask = 3536;
//; $tls::sigwait_info = -9256;
//; $tls::psigwait_info = 3544;
//; $tls::signal_arrived = -9248;
//; $tls::psignal_arrived = 3552;
//; $tls::will_wait_for_signal = -9240;
//; $tls::pwill_wait_for_signal = 3560;
//; $tls::thread_context = -9232;
//; $tls::pthread_context = 3568;
//; $tls::thread_id = -8400;
//; $tls::pthread_id = 4400;
//; $tls::infodata = -8396;
//; $tls::pinfodata = 4404;
//; $tls::tid = -8248;
//; $tls::ptid = 4552;
//; $tls::_ctinfo = -8240;
//; $tls::p_ctinfo = 4560;
//; $tls::andreas = -8232;
//; $tls::pandreas = 4568;
//; $tls::wq = -8224;
//; $tls::pwq = 4576;
//; $tls::sig = -8176;
//; $tls::psig = 4624;
//; $tls::incyg = -8172;
//; $tls::pincyg = 4628;
//; $tls::spinning = -8168;
//; $tls::pspinning = 4632;
//; $tls::stacklock = -8164;
//; $tls::pstacklock = 4636;
//; $tls::stackptr = -8160;
//; $tls::pstackptr = 4640;
//; $tls::stack = -8152;
//; $tls::pstack = 4648;
//; $tls::initialized = -6104;
//; $tls::pinitialized = 6696;
//; $tls::local_clib = -10560;
//; $tls::plocal_clib = 2240;
//; $tls::__dontuse = -10560;
//; $tls::p__dontuse = 2240;
//; $tls::func = -8672;
//; $tls::pfunc = 4128;
//; $tls::saved_errno = -8664;
//; $tls::psaved_errno = 4136;
//; $tls::sa_flags = -8660;
//; $tls::psa_flags = 4140;
//; $tls::oldmask = -8656;
//; $tls::poldmask = 4144;
//; $tls::deltamask = -8648;
//; $tls::pdeltamask = 4152;
//; $tls::errno_addr = -8640;
//; $tls::perrno_addr = 4160;
//; $tls::sigmask = -8632;
//; $tls::psigmask = 4168;
//; $tls::sigwait_mask = -8624;
//; $tls::psigwait_mask = 4176;
//; $tls::sigwait_info = -8616;
//; $tls::psigwait_info = 4184;
//; $tls::signal_arrived = -8608;
//; $tls::psignal_arrived = 4192;
//; $tls::will_wait_for_signal = -8600;
//; $tls::pwill_wait_for_signal = 4200;
//; $tls::thread_context = -8592;
//; $tls::pthread_context = 4208;
//; $tls::thread_id = -7760;
//; $tls::pthread_id = 5040;
//; $tls::infodata = -7756;
//; $tls::pinfodata = 5044;
//; $tls::tid = -7608;
//; $tls::ptid = 5192;
//; $tls::_ctinfo = -7600;
//; $tls::p_ctinfo = 5200;
//; $tls::andreas = -7592;
//; $tls::pandreas = 5208;
//; $tls::wq = -7584;
//; $tls::pwq = 5216;
//; $tls::sig = -7536;
//; $tls::psig = 5264;
//; $tls::incyg = -7532;
//; $tls::pincyg = 5268;
//; $tls::spinning = -7528;
//; $tls::pspinning = 5272;
//; $tls::stacklock = -7524;
//; $tls::pstacklock = 5276;
//; $tls::stackptr = -7520;
//; $tls::pstackptr = 5280;
//; $tls::stack = -7512;
//; $tls::pstack = 5288;
//; $tls::initialized = -5464;
//; $tls::pinitialized = 7336;
//; __DATA__
#define tls_locals (-12800)
#define tls_plocals (0)
#define tls_local_clib (-11200)
#define tls_plocal_clib (1600)
#define tls___dontuse (-11200)
#define tls_p__dontuse (1600)
#define tls_func (-9312)
#define tls_pfunc (3488)
#define tls_saved_errno (-9304)
#define tls_psaved_errno (3496)
#define tls_sa_flags (-9300)
#define tls_psa_flags (3500)
#define tls_oldmask (-9296)
#define tls_poldmask (3504)
#define tls_deltamask (-9288)
#define tls_pdeltamask (3512)
#define tls_errno_addr (-9280)
#define tls_perrno_addr (3520)
#define tls_sigmask (-9272)
#define tls_psigmask (3528)
#define tls_sigwait_mask (-9264)
#define tls_psigwait_mask (3536)
#define tls_sigwait_info (-9256)
#define tls_psigwait_info (3544)
#define tls_signal_arrived (-9248)
#define tls_psignal_arrived (3552)
#define tls_will_wait_for_signal (-9240)
#define tls_pwill_wait_for_signal (3560)
#define tls_thread_context (-9232)
#define tls_pthread_context (3568)
#define tls_thread_id (-8400)
#define tls_pthread_id (4400)
#define tls_infodata (-8396)
#define tls_pinfodata (4404)
#define tls_tid (-8248)
#define tls_ptid (4552)
#define tls__ctinfo (-8240)
#define tls_p_ctinfo (4560)
#define tls_andreas (-8232)
#define tls_pandreas (4568)
#define tls_wq (-8224)
#define tls_pwq (4576)
#define tls_sig (-8176)
#define tls_psig (4624)
#define tls_incyg (-8172)
#define tls_pincyg (4628)
#define tls_spinning (-8168)
#define tls_pspinning (4632)
#define tls_stacklock (-8164)
#define tls_pstacklock (4636)
#define tls_stackptr (-8160)
#define tls_pstackptr (4640)
#define tls_stack (-8152)
#define tls_pstack (4648)
#define tls_initialized (-6104)
#define tls_pinitialized (6696)
#define tls_local_clib (-10560)
#define tls_plocal_clib (2240)
#define tls___dontuse (-10560)
#define tls_p__dontuse (2240)
#define tls_func (-8672)
#define tls_pfunc (4128)
#define tls_saved_errno (-8664)
#define tls_psaved_errno (4136)
#define tls_sa_flags (-8660)
#define tls_psa_flags (4140)
#define tls_oldmask (-8656)
#define tls_poldmask (4144)
#define tls_deltamask (-8648)
#define tls_pdeltamask (4152)
#define tls_errno_addr (-8640)
#define tls_perrno_addr (4160)
#define tls_sigmask (-8632)
#define tls_psigmask (4168)
#define tls_sigwait_mask (-8624)
#define tls_psigwait_mask (4176)
#define tls_sigwait_info (-8616)
#define tls_psigwait_info (4184)
#define tls_signal_arrived (-8608)
#define tls_psignal_arrived (4192)
#define tls_will_wait_for_signal (-8600)
#define tls_pwill_wait_for_signal (4200)
#define tls_thread_context (-8592)
#define tls_pthread_context (4208)
#define tls_thread_id (-7760)
#define tls_pthread_id (5040)
#define tls_infodata (-7756)
#define tls_pinfodata (5044)
#define tls_tid (-7608)
#define tls_ptid (5192)
#define tls__ctinfo (-7600)
#define tls_p_ctinfo (5200)
#define tls_andreas (-7592)
#define tls_pandreas (5208)
#define tls_wq (-7584)
#define tls_pwq (5216)
#define tls_sig (-7536)
#define tls_psig (5264)
#define tls_incyg (-7532)
#define tls_pincyg (5268)
#define tls_spinning (-7528)
#define tls_pspinning (5272)
#define tls_stacklock (-7524)
#define tls_pstacklock (5276)
#define tls_stackptr (-7520)
#define tls_pstackptr (5280)
#define tls_stack (-7512)
#define tls_pstack (5288)
#define tls_initialized (-5464)
#define tls_pinitialized (7336)