All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Georgi <patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
To: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Patrick Georgi <patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
Subject: [PATCH 4/5] set: check seek success
Date: Thu,  2 Oct 2014 10:16:27 +0200	[thread overview]
Message-ID: <1412237788-20611-4-git-send-email-patrick@georgi-clan.de> (raw)
In-Reply-To: <1412237788-20611-1-git-send-email-patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>

This could silently fail which leads to surprising behaviour.

Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
---
 src/set.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/set.c b/src/set.c
index ff32b53..907d640 100644
--- a/src/set.c
+++ b/src/set.c
@@ -59,7 +59,11 @@ read_from_image(char	*filename,
 		return result;
 	}
 
-	fseek(fp, offset, SEEK_SET);
+	if (!fseek(fp, offset, SEEK_SET)) {
+		printf("Error: Couldn't seek to %s(%d)\n", filename, offset);
+		result = 1;
+		goto cleanup;
+	}
 
 	if (stat(filename, &stats) != 0) {
 		printf("Error: Unable to query info on bootloader path %s\n",
-- 
1.9.1

  parent reply	other threads:[~2014-10-02  8:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02  8:16 [PATCH 1/5] configure.ac: Don't search for c++ compiler Patrick Georgi
     [not found] ` <1412237788-20611-1-git-send-email-patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-02  8:16   ` [PATCH 2/5] cbootimage: simplify code Patrick Georgi
2014-10-02  8:16   ` [PATCH 3/5] data_layout: improve memory handling Patrick Georgi
2014-10-02  8:16   ` Patrick Georgi [this message]
     [not found]     ` <1412237788-20611-4-git-send-email-patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-02 22:58       ` [PATCH 4/5] set: check seek success Stephen Warren
     [not found]         ` <542DD8A7.7040705-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-10-03  6:54           ` Patrick Georgi
     [not found]             ` <542E4817.1000604-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-03 15:38               ` Stephen Warren
2014-10-02  8:16   ` [PATCH 5/5] data_layout: fail better on file access errors Patrick Georgi
2014-10-02 23:09   ` [PATCH 1/5] configure.ac: Don't search for c++ compiler Stephen Warren
2014-11-08 22:14   ` [PATCH 4/5 v2] set: check seek success Patrick Georgi
     [not found]     ` <545E95B1.5030703-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-11-09  1:04       ` Thierry Reding
     [not found]         ` <14992150720.2771.879d79c6f3490faa837fa11cb97f42bf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-09  7:57           ` Patrick Georgi
2014-11-10  8:51       ` Thierry Reding
2014-11-10  9:08         ` Thierry Reding
2014-11-10 16:31         ` Stephen Warren
     [not found]           ` <5460E87B.1040209-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-11-17 11:32             ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412237788-20611-4-git-send-email-patrick@georgi-clan.de \
    --to=patrick-u1irdzu7gsckt1dfyrw6gg@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.