Re: [PATCH] system_path: use a static buffer
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Mar 18, 2011, 10:34 UTC
- Message-ID
- <AANLkTikms3Ek1CgQHg+gT8Eqs2K6PCvOB-kWZ-aqGawg@mail.gmail.com>
- In-Reply-To
- <1300371853-8965-1-git-send-email-cmn@elego.de>
On Thu, Mar 17, 2011 at 9:24 PM, Carlos Martín Nieto <cmn@elego.de> wrote:
> - static const char *system_wide; > - if (!system_wide) > - system_wide = system_path(ETC_GITATTRIBUTES); > + static char system_wide[PATH_MAX];
...
> - static const char *system_wide; > - if (!system_wide) > - system_wide = system_path(ETC_GITCONFIG); > + static char system_wide[PATH_MAX];
...
Show 9 quoted lines
> #ifdef RUNTIME_PREFIX > - static const char *prefix; > + static const char *prefix = NULL; > #else > static const char *prefix = PREFIX; > #endif > - struct strbuf d = STRBUF_INIT; > + static char buf[PATH_MAX]; > + int ret;
It was pointed out elsewhere [1] that PATH_MAX only specifies max length of a path element, not full path. I think we'd need to stay away from preallocated PATH_MAX-sized arrays.
[1] http://mid.gmane.org/AANLkTikXvx7-Q8B_dqG5mMHGK_Rw-dFaeQdXi0zW98SD@mail.gmail.com
-- Duy