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

Arnaldo Carvalho de Melo
2013-10-14T13:13:46Z

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;
> + }
> +}