[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5163E57E.5030705@asianux.com>
Date: Tue, 09 Apr 2013 17:55:10 +0800
From: Chen Gang <gang.chen@...anux.com>
To: Rusty Russell <rusty@...tcorp.com.au>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel: module: strncpy issue, using strlcpy instead
of strncpy
On 2013年04月09日 17:36, Chen Gang wrote:
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 487ac6f..9ec6d1f 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -145,13 +145,15 @@ static int read_symbol(FILE *in, struct sym_entry *s)
> /* include the type field in the symbol name, so that it gets
> * compressed together */
> s->len = strlen(str) + 1;
> + if (s->len > KSYM_NAME_LEN)
> + s->len = KSYM_NAME_LEN;
> s->sym = malloc(s->len + 1);
> if (!s->sym) {
> fprintf(stderr, "kallsyms failure: "
> "unable to allocate required amount of memory\n");
> exit(EXIT_FAILURE);
> }
> - strcpy((char *)s->sym + 1, str);
> + strlcpy((char *)s->sym + 1, str, KSYM_NAME_LEN);
> s->sym[0] = stype;
>
oh... it is a user mode program which no strlcpy in lib C !!
(so this diff is just really for a reference, not for the real using)
:-)
--
Chen Gang
Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists