From: Karsten Blees <karsten.blees@gmail.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git List <git@vger.kernel.org>,
msysGit <msysgit@googlegroups.com>, Jeff King <peff@peff.net>
Subject: Re: [PATCH 2/2] dir: remove PATH_MAX limitation
Date: Fri, 11 Jul 2014 21:10:59 +0200 [thread overview]
Message-ID: <53C036C3.10103@gmail.com> (raw)
In-Reply-To: <CACsJy8AXAusNHb5GJgrcbgzXY-1_ER2CNmah=vkJzOgPHMHudA@mail.gmail.com>
Am 05.07.2014 12:48, schrieb Duy Nguyen:
> On Sat, Jul 5, 2014 at 5:42 AM, Karsten Blees <karsten.blees@gmail.com> wrote:
>> 'git status' segfaults if a directory is longer than PATH_MAX, because
>> processing .gitignore files in prep_exclude() writes past the end of a
>> PATH_MAX-bounded buffer.
>>
>> Remove the limitation by using strbuf instead.
>>
>> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.
>> prep_exclude() can probably be simplified using more strbuf APIs.
>
> FYI I had a similar patch [1] that attempted to lazily strbuf_init()
> instead so that strbuf_ API could be used.
>
> [1] http://article.gmane.org/gmane.comp.version-control.git/248310
>
Sorry, I missed that one.
In my version, strbuf_grow() does the lazy initialization (in fact, many
strbuf_* functions can handle memset(0) strbufs just fine).
I was simply too lazy to understand (again) how prep_exclude works exactly, and
as string calculations like that have the tendency to be just 1 char off, I went
for the obviously correct solution (i.e. s/dir->basebuf/dir->base.buf/ plus
strbuf_grow() before we write the buffer).
But IMO your version is much cleaner already.
However, api-strbuf.txt says that buf != NULL is invariant after init, and
alloc is "somehow private" :-) , so perhaps you should
- if (!dir->basebuf.alloc)
+ if (!dir->basebuf.buf)
strbuf_init(&dir->basebuf, PATH_MAX);
--
--
*** 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/d/optout.
next prev parent reply other threads:[~2014-07-11 19:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-04 22:41 [PATCH 1/2] symlinks: remove PATH_MAX limitation Karsten Blees
2014-07-04 22:42 ` [PATCH 2/2] dir: " Karsten Blees
2014-07-05 10:48 ` Duy Nguyen
2014-07-11 19:10 ` Karsten Blees [this message]
2014-07-09 5:42 ` Jeff King
2014-07-09 16:33 ` Junio C Hamano
2014-07-11 19:11 ` Karsten Blees
2014-07-11 22:29 ` Junio C Hamano
2014-07-11 23:43 ` Karsten Blees
2014-07-12 2:56 ` Duy Nguyen
2014-07-14 4:29 ` Junio C Hamano
2014-07-05 2:52 ` [PATCH 1/2] symlinks: " Johannes Schindelin
2014-07-07 18:30 ` Junio C Hamano
2014-07-11 19:11 ` Karsten Blees
2014-07-11 22:19 ` Junio C Hamano
2014-07-11 23:02 ` [PATCH] fixup! " Karsten Blees
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53C036C3.10103@gmail.com \
--to=karsten.blees@gmail.com \
--cc=git@vger.kernel.org \
--cc=msysgit@googlegroups.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).