Re: [PATCH] kernel: module: strncpy issue, using strlcpy insteadof strncpy

From: Chen Gang
Date: Tue Apr 09 2013 - 05:55:56 EST


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/