On Mon, 30 Oct 2023 at 21:19, Richard Henderson <richard.hender...@linaro.org> wrote: > > This tool will be used for post-processing the linked vdso image, > turning it into something that is easy to include into elfload.c. > > Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org> > Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
Hi; Coverity complains about the lack of error-checking here (CID 1523742): > + /* > + * Read the input file into a buffer. > + * We expect the vdso to be small, on the order of one page, > + * therefore we do not expect a partial read. > + */ > + fseek(inf, 0, SEEK_END); > + total_len = ftell(inf); > + fseek(inf, 0, SEEK_SET); > + > + buf = malloc(total_len); We don't check for errors from fseek() or ftell(). In particular this means that if ftell() returned -1 we pass -1 to malloc(), which isn't valid. > + if (buf == NULL) { > + goto perror_inf; > + } This could all be sidestepped by using glib, which would give us the higher level g_file_get_contents(), rather than spending 20 lines doing it with POSIX APIs. thanks -- PMM