All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] gen_init_cpio: allocate enough space for dname
Date: Tue, 21 Mar 2017 17:02:14 +0000	[thread overview]
Message-ID: <58D15C96.7010100@bfs.de> (raw)
In-Reply-To: <20170321164439.30828-1-colin.king@canonical.com>



Am 21.03.2017 17:44, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The allocation of dname is short by 1 byte, so increase the allocation
> size.
> 
> Detected with CoverityScan, CID#711628 ("Out-of-bounds-access (OVERRUN)")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  usr/gen_init_cpio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
> index 225ad244cf88..981682f4faea 100644
> --- a/usr/gen_init_cpio.c
> +++ b/usr/gen_init_cpio.c
> @@ -418,7 +418,7 @@ static int cpio_mkfile_line(const char *line)
>  		int len;
>  		int nend;
>  
> -		dname = malloc(strlen(line));
> +		dname = malloc(strlen(line) + 1);
>  		if (!dname) {
>  			fprintf (stderr, "out of memory (%d)\n", dname_len);
>  			goto fail;


this is a case for strdup()

re,
 wh

      reply	other threads:[~2017-03-21 17:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21 16:44 [PATCH] gen_init_cpio: allocate enough space for dname Colin King
2017-03-21 17:02 ` walter harms [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58D15C96.7010100@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.