diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2025-07-10 18:07:06 +0100 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-07-10 11:57:35 -0600 |
| commit | ff3b0e8d326155e45574dd14de5db6702a32d06e (patch) | |
| tree | 34d341017e2f270dffc4f2f7bdde8066cb394894 | |
| parent | c4828cb8502d0b2adc39b9cde93df7d2886df897 (diff) | |
| download | focaccia-qemu-ff3b0e8d326155e45574dd14de5db6702a32d06e.tar.gz focaccia-qemu-ff3b0e8d326155e45574dd14de5db6702a32d06e.zip | |
linux-user/gen-vdso: Handle fseek() failure
Coverity points out that we don't check for fseek() failure in gen-vdso.c, and so we might pass -1 to malloc(). Add the error checking. (This is a standalone executable that doesn't link against glib, so we can't do the easy thing and use g_file_get_contents().) Coverity: CID 1523742 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250710170707.1299926-2-peter.maydell@linaro.org>
| -rw-r--r-- | linux-user/gen-vdso.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/linux-user/gen-vdso.c b/linux-user/gen-vdso.c index fce9d5cbc3..1c406d1b10 100644 --- a/linux-user/gen-vdso.c +++ b/linux-user/gen-vdso.c @@ -113,9 +113,16 @@ int main(int argc, char **argv) * 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); + if (fseek(inf, 0, SEEK_END) < 0) { + goto perror_inf; + } total_len = ftell(inf); - fseek(inf, 0, SEEK_SET); + if (total_len < 0) { + goto perror_inf; + } + if (fseek(inf, 0, SEEK_SET) < 0) { + goto perror_inf; + } buf = malloc(total_len); if (buf == NULL) { |