Re: [PATCH] mailmap: xcalloc mailmap_info

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

 



Marc-André Lureau <marcandre.lureau@xxxxxxxxx> writes:

> This is to avoid reaching free of uninitialized members.
>
> With an invalid .mailmap (and perhaps in other cases), it can reach
> free(mi->name) with garbage for example.
> ---

Sign-off?

Thanks. We might want to turn xmalloc() followed by memset(,0,) for the
allocation of the mailmap entry itself in the same function, but that is a
minor issue.

>  mailmap.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mailmap.c b/mailmap.c
> index 02fcfde..fbf7764 100644
> --- a/mailmap.c
> +++ b/mailmap.c
> @@ -88,7 +88,7 @@ static void add_mapping(struct string_list *map,
>  			me->email = xstrdup(new_email);
>  		}
>  	} else {
> -		struct mailmap_info *mi = xmalloc(sizeof(struct mailmap_info));
> +		struct mailmap_info *mi = xcalloc(1, sizeof(struct mailmap_info));
>  		debug_mm("mailmap: adding (complex) entry for %s at index %d\n", old_email, index);
>  		if (new_name)
>  			mi->name = xstrdup(new_name);
--
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]