Re: [PATCH V7 5/7] perf buildid-cache: add ability to add kcore tothe cache

From: Arnaldo Carvalho de Melo
Date: Mon Oct 14 2013 - 09:13:49 EST


Em Mon, Oct 14, 2013 at 01:43:42PM +0300, Adrian Hunter escreveu:
> +static int kcore_copy__compare_fds(int from, int to)
<SNIP>
> + while (1) {
> + /* Use read because mmap won't work on proc files */
> + ret = read(from, buf_from, page_size);
> + if (ret < 0)
> + return -1;
> + if (!ret)
> + return 0;
> + n = ret;
> + len = ret;
> + while (n) {
> + ret = read(to, buf_to, n);
> + if (ret <= 0)
> + return -1;
> + n -= ret;

You can't go on potentially rewriting 'buf_to' like that, consider using
readn().

> + }
> +
> + if (memcmp(buf_from, buf_to, len))
> + return -1;
> + }
> +}
--
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/