From 9ef09467387640d9e32c280fd956567ffdfb2544 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 13 Jun 2024 21:26:01 +0200 Subject: [PATCH] pkcs15-init: Check return value of fseek Thanks coverity CID 426268 --- src/tools/pkcs15-init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index 3759e252ee..61aa9bfbb7 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -2504,11 +2504,16 @@ static size_t determine_filesize(const char *filename) { FILE *fp; long ll; + int rc; - if ((fp = fopen(filename,"rb")) == NULL) + fp = fopen(filename,"rb"); + if (fp == NULL) util_fatal("Unable to open %s: %m", filename); - fseek(fp,0L,SEEK_END); + rc = fseek(fp, 0L, SEEK_END); + if (rc != 0) + util_fatal("Unable seek in the opened file %s", filename); + ll = ftell(fp); if (ll == -1l) util_fatal("fseek/ftell error");