Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

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

 



On Wed, Oct 23, 2013 at 2:55 PM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
> The old code does not do boundary check so any paths longer than
> PATH_MAX can cause buffer overflow. Replace it with strbuf to handle
> paths of arbitrary length.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
>  To get this topic going again. These two patches kill PATH_MAX in
>  entry.c and builtin/checkout-index.c

Thanks !

> diff --git a/entry.c b/entry.c
> index acc892f..d955af5 100644
> --- a/entry.c
> +++ b/entry.c
> @@ -237,16 +237,18 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)
>  int checkout_entry(struct cache_entry *ce,
>                    const struct checkout *state, char *topath)
>  {
> -       static char path[PATH_MAX + 1];
> +       static struct strbuf path_buf = STRBUF_INIT;
> +       char *path;
>         struct stat st;
> -       int len = state->base_dir_len;
> +       int len;
>
>         if (topath)
>                 return write_entry(ce, topath, state, 1);
>
> -       memcpy(path, state->base_dir, len);
> -       strcpy(path + len, ce->name);
> -       len += ce_namelen(ce);
> +       strbuf_reset(&path_buf);

I think this is not required
--
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]