summaryrefslogtreecommitdiffstats
path: root/commands/crc.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2012-06-27 11:08:33 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-07-17 20:41:17 +0200
commitb78e5fe9f3ce155065831d3aa8a480656a8f53c5 (patch)
tree92e3e8323b8bbf67929f552bca2842c3dc47764a /commands/crc.c
parent2f6b1f7690640f571f8e72fc2f2564acb2e13778 (diff)
downloadbarebox-b78e5fe9f3ce155065831d3aa8a480656a8f53c5.tar.gz
barebox-b78e5fe9f3ce155065831d3aa8a480656a8f53c5.tar.xz
commands/crc: assert newline after output with big offsets
This fixes barebox@Very long board name:/ crc32 -f /dev/mem 0x83f00000+0xfff CRC32 for /dev/mem 0x83fff000 ... 0x83fffffe ==> 0xa080584bbarebox@Very long board name:/ The problem here was that the return value of lseek(fd, 0x83f00000, SEEK_SET) (which is 0x83f00000) was casted to an int (which is -2081423360), returned to do_crc and interpreted as error there without yielding another error message. This also makes crc32 -f /dev/mem 0xffffffff+0x1 die on a NULL pointer exception instead of reporting: lseek: No error :-) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/crc.c')
-rw-r--r--commands/crc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/commands/crc.c b/commands/crc.c
index 09af6aa3f9..8f80e424fd 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -47,9 +47,12 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc,
}
if (start > 0) {
- ret = lseek(fd, start, SEEK_SET);
- if (ret == -1) {
+ off_t lseek_ret;
+ errno = 0;
+ lseek_ret = lseek(fd, start, SEEK_SET);
+ if (lseek_ret == (off_t)-1 && errno) {
perror("lseek");
+ ret = -1;
goto out;
}
}