git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Setup.c: PATH_MAX is the length including the Nil

From
FKFaiz Kothari <faiz.off93@gmail.com>
Date
Mar 4, 2014, 16:49 UTC
Message-ID
<CAFbjVc=bt4NX2uAPx98YCqEh_gKY=KVsm1iFHU8N86aqKL3VoQ@mail.gmail.com>
In-Reply-To
<1393950550-9668-1-git-send-email-sunheehnus@gmail.com>
On Tue, Mar 4, 2014 at 9:59 PM, Sun He <sunheehnus@gmail.com> wrote:
Show 16 quoted lines
> Signed-off-by: Sun He <sunheehnus@gmail.com>
> ---
>
> Check the limit.h of linux and find out that the MACRO
> #define PATH_MAX        4096    /* # chars in a path name including nul */
> So if the magic number 40 is just the size it should be. (e.g. hash code)
> It may bring bugs with the length(4056) of long name(gitdirenv).
> As gitdirenv could be set by GIT_DIR_ENVIRONMENT.
> If it is a bug, it will almost never occur.
> But I need your help to know if there is the PATH_MAX of git is the mirror of the
> PATH_MAX of linux and if this fix is right?
> If it was, there may be many places like "PATH_MAX + 1" could be replaced by
> just "PATH_MAX". And there may be many places like this.
>
> Cheers,
> He Sun

Hi, I am not getting what exactly you are trying to tell, but git defines its own PATH_MAX. Its defined in git-compat-util.h: #define PATH_MAX 4096 That is why instead of making buffers using PATH_MAX, use strbuf. All these problems of buffer overflow will be gone. I hope you are concerned about buffer overflow.

Cheers
-Faiz
Previous: Sun He
Message 2 of 2 in “Setup.c: PATH_MAX is the length including the Nil”
  1. Setup.c: PATH_MAX is the length including the NilSun He, Mar 4, 2014
  2. Faiz KothariMar 4, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.