Re: [BUG/PATCH] setup: Copy an environment variable to avoid overwrites

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 5, 2013 at 7:35 AM, David Michael <fedora.dm0@xxxxxxxxx> wrote:
> -    if (gitdirenv)
> -        return setup_explicit_git_dir(gitdirenv, cwd, len, nongit_ok);
> +    if (gitdirenv) {
> +        gitdirenv = xstrdup(gitdirenv);
> +        ret = setup_explicit_git_dir(gitdirenv, cwd, len, nongit_ok);
> +        free(gitdirenv);
> +        return ret;
> +    }

Maybe we could all this into a wrapper? If getenv() here has a
problem, many other places may have the same problem too. This
simplifies the change. But one has to check that getenv() must not be
used in threaded code.

char *git_getenv(const char *env)
{
   static int bufno;
   static char *buf[4];
   bufno = (bufno + 1) % 4;
   free(buf[bufno]);
   buf[bufno] = xstrdup(getenv(env));
   return buf[bufno];
}
#define getenv(x) git_getenv(x)

-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]