* [PATCH] gen_init_cpio: allocate enough space for dname
@ 2017-03-21 16:44 Colin King
2017-03-21 17:02 ` walter harms
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-03-21 16:44 UTC (permalink / raw)
To: kernel-janitors; +Cc: linux-kernel
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;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gen_init_cpio: allocate enough space for dname
2017-03-21 16:44 [PATCH] gen_init_cpio: allocate enough space for dname Colin King
@ 2017-03-21 17:02 ` walter harms
0 siblings, 0 replies; 2+ messages in thread
From: walter harms @ 2017-03-21 17:02 UTC (permalink / raw)
To: kernel-janitors
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-21 17:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-21 16:44 [PATCH] gen_init_cpio: allocate enough space for dname Colin King
2017-03-21 17:02 ` walter harms
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.