Re: [PATCH] Prevent buffer overflows when path is too big
- From
Antoine Pelisse <apelisse@gmail.com>
- Date
- Oct 20, 2013, 17:57 UTC
- Message-ID
- <CALWbr2z1RmLLNa3Cj+n6g=zu5FB4VZSmRTU1qYb86pXLfYGJGg@mail.gmail.com>
- In-Reply-To
- <CACsJy8AXV=KJtTWxp6dpfa_Pr81h3YwW5EK=c_dV=F7tr7ChWQ@mail.gmail.com>
My main motive was to not *stop* the process when a long path is met. Because somebody created a repository on Linux with a long file-name doesn't mean you should not be able to clone it *at all* on Windows.
On Sun, Oct 20, 2013 at 12:33 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Sun, Oct 20, 2013 at 12:47 PM, Torsten Bögershausen <tboegi@web.de> wrote: >> I'm not sure how to handle overlong path in general, there are several ways: >> a) Silently overwrite memory (with help of memcpy() and/or strcpy()
This one stop the process, as the application crashes :-)
>> b) Silently shorten the path using strlcpy() instead of strcpy()
I was expecting this solution to fail later in a non-blocking way (e.g. "Can't checkout file $truncated_path, continuing with other files"). Maybe it would be better to look at each specific call site and see if there is a way to report a problem ('return error("Can't checkout %s: path too long")')
>> c) Avoid the overwriting and call die().
This one also stops the process, with an error (of course that's better than point a)
>> d) Prepare a longer buffer using xmalloc() > d+) Use strbuf
This of course looks like the best solution, but I believe PATH_MAX exists for a reason, and maybe we can't simply ignore that value ?
-- -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en --- You received this message because you are subscribed to the Google Groups "msysGit" group. To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.