Re: [msysGit] [PATCH] mingw-multibyte: fix memory acces violation and path length limits.

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

 



Hi,

On Sun, 29 Sep 2013, Wataru Noguchi wrote:

> --- a/convert.c
> +++ b/convert.c
> @@ -724,6 +724,11 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
>  {
>  	int i;
>  	static struct git_attr_check ccheck[NUM_CONV_ATTRS];
> +	
> +	if (NUM_CONV_ATTRS != 0) {
> +		ccheck[0].attr = NULL;
> +		ccheck[0].value = NULL;
> +	}

I wonder whether it would make more sense to use

	memset(ccheck, 0, sizeof(ccheck))

? But then, ccheck is static and *should* be initialized to all 0
according to the C standard. And re-initializing it to NULL would
invalidate the values that were set earlier.

Also, if NUM_CONV_ATTRS == 0, I would expect

>  	if (!ccheck[0].attr) {

to access an invalid location...

> diff --git a/git-compat-util.h b/git-compat-util.h
> index a31127f..ba02c69 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -237,6 +237,16 @@ extern char *gitbasename(char *);
>  #ifndef PATH_MAX
>  #define PATH_MAX 4096
>  #endif
> +#ifdef GIT_WINDOWS_NATIVE
> +/* Git for Windows checkout PATH_MAX is reduce to 260.
> + * but if checkout relative long path name, its length too short.
> + * thus, expand length.
> + */
> +#ifdef PATH_MAX
> +#undef PATH_MAX
> +#endif
> +#define PATH_MAX 4096
> +#endif

This looks fine, but I am wary... did you not say that a crash was caused
by this? In that case, we would have a user that accesses the respective
buffer without checking the size and we would still have to fix that bug..

Ciao,
Dscho
--
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]