On Thu, Sep 20, 2012 at 09:54:05AM -0400, Charles Campbell wrote: > Danek Duvall wrote: > ><snip> > >In os_unix.c, the path we trace through mch_FullName() grabs the cwd into > >"buf" > >(an input parameter) with mch_dirname(), which succeeds, since it's just > >short > >enough to fit into the 1024-byte buffer (with the trailing NUL). We then get > >the strlen() of buf, returning 1023, as the truss output shows on line 72731. > >We then compare that value to the input parameter "len", which is the size of > >"buf", and since 1023 is not>= 1024, we assume we can add a slash to the end, > >overwriting the end of the buffer. > <snip> > > Shouldn't the buffer size (1024 mentioned above) be set, at least > under unix, to a value at least as large as indicated by pathconf()?
Yeah, that's a decent idea, but non-trivial. Looks like (at least for this codepath) it's allocated in FullName_save() in misc1.c. Dunno about other possibilities, but you'd have to track them all down, as well as pass around a buffer length, or call pathconf() again every time you need to know the length. It's also possible for getcwd() to return a buffer larger than MAXPATHLEN, but handling that, particularly across different implementations, also seemed trickier than I particularly felt like handling. Danek -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
