Re: Minor patch to correct buffer overrun

Eli Zaretskii <[email protected]>
Newsgroups gmane.comp.gnu.make.windows
Message-ID <[email protected]>
> From: Paul Smith <[email protected]>
> Cc: Chris Sutcliffe <[email protected]>, [email protected]
> Date: Wed, 18 Aug 2010 13:32:39 -0400
> 
> On Wed, 2010-08-18 at 20:19 +0300, Eli Zaretskii wrote:
> > Can you explain what exactly was the problem with the original code?
> 
> Well, if the size of tem was MAXPATHLEN, but the size of name was
> PATH_MAX or similar, and PATH_MAX is 1024 and MAXPATHLEN is 269 (or
> whatever it was), and your filename is long... that's a problem.

But `name' is a file name of a directory on Windows, and Windows
directories simply cannot have names longer than 259 characters.  So I
don't see how this potential problem could actually happen.

> I think the right fix is the one we were discussing earlier: all code
> that wants a static buffer large enough to house a pathname should be
> changed to use PATH_MAX, and we can tweak out make.h to set PATH_MAX to
> a useful value on any system where it's not yet set.

That's okay, but PATH_MAX and MAXPATHLEN are the same on Windows, the
value is 259.  So if there is a problem in this code, it will still
exist after the change you propose.  That's why I asked Chris to
provide more data, like the actual length of the file name that
allegedly caused the crash.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.