From c3e2dc90057cc531a19aafcf65c5916dabceb2ef Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 11 May 2014 23:45:42 +0100 Subject: check return values of fseek (fixes coverity 1109840) --- utils/container.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/utils/container.c b/utils/container.c index 3e03e15f1..9ffe7f5c0 100644 --- a/utils/container.c +++ b/utils/container.c @@ -382,15 +382,17 @@ void container_close(struct container_ctx *ctx) flen = (flen + 3) & (~3); /* round up to nearest 4 bytes */ /* write this location to the header */ - fseek(ctx->fh, 104, SEEK_SET); - nflen = htonl(flen); - val = fwrite(&nflen, 4, 1, ctx->fh); - if (val == 0) - LOG(("empty write directory location")); + if (fseek(ctx->fh, 104, SEEK_SET) == 0) { + nflen = htonl(flen); + val = fwrite(&nflen, 4, 1, ctx->fh); + if (val == 0) + LOG(("empty write directory location")); - /* seek to where the directory will be, and write it */ - fseek(ctx->fh, flen, SEEK_SET); - container_write_dir(ctx); + /* seek to where the directory will be, and write it */ + if (fseek(ctx->fh, flen, SEEK_SET) == 0) { + container_write_dir(ctx); + } + } } else if (ctx->processed) { #ifdef WITH_MMAP -- cgit v1.2.3