From 54cf00ba6e2cbea815d684415426ad28de9953fd Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 2 Sep 2023 16:11:44 +0200 Subject: jffs2dump: check return value of lseek On error, lseek returns a negative value. We need to check for that and abort, instead of passing -1 to malloc and later on to read_nocheck. Signed-off-by: David Oberhollenzer --- jffsX-utils/jffs2dump.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jffsX-utils/jffs2dump.c b/jffsX-utils/jffs2dump.c index d30b59f..30455ea 100644 --- a/jffsX-utils/jffs2dump.c +++ b/jffsX-utils/jffs2dump.c @@ -757,6 +757,12 @@ int main(int argc, char **argv) // get image length imglen = lseek(fd, 0, SEEK_END); + if (imglen < 0) { + perror(img); + close(fd); + exit(EXIT_FAILURE); + } + lseek (fd, 0, SEEK_SET); data = malloc (imglen); -- cgit v1.2.3