On 03/10/2007, Paul Smith <[EMAIL PROTECTED]> wrote: > On Wed, 2007-10-03 at 14:31 +0200, Eli Zaretskii wrote: > > To be on the safe side with this issue, we really need to call > > pathconf to get the correct values. (It will need to be emulated on > > Windows, but that isn't hard, at least as far as _POSIX_PATH_MAX and > > _POSIX_NAME_MAX are concerned.) If pathconf returns something greater > > than a few KB, I'd suggest to avoid alloca or any other stack-based > > allocations. > > The thing is, even if pathnames are ALLOWED to be very long, the chances > that they actually ARE very long are exceedingly slim (especially for > GNU make, which generally deals with real files in real directories > rather than artificially created ones). So, alloca() is a good fit... > except in those very, very, VERY rare situations where it's not. And, > as has been pointed out, using a char x[MAXPATHLEN] is even more > susceptible to stack overflow as alloca()... or else it's susceptible to > buffer overflow, which is even worse!
Well said. :-) > The only real solution is to avoid alloca() and use malloc() everywhere. I do not like heap allocation here, which is vastly slower, and will really make the Windows fix very, very ugly. > Or else rewrite make in C++. I like C++. Rewriting does not look worth while. > Or else go with a garbage collector. You do have a very open mind.... I am more conservative. Best regards, Yongwei -- Wu Yongwei URL: http://wyw.dcweb.cn/ _______________________________________________ Make-w32 mailing list [email protected] http://lists.gnu.org/mailman/listinfo/make-w32
