summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2013-07-02 21:03:18 +0200
committerHelge Deller <deller@gmx.de>2013-07-02 21:03:18 +0200
commit55d6734622df6a2e790199eb47a013793257e0ec (patch)
treebeaff31535cc650a3b3da559274e644af20d9149
parent4d9c97ec5cc22de5a2d30e9fd4d0d6ae5f6600da (diff)
downloadpalo-55d6734622df6a2e790199eb47a013793257e0ec.tar.gz
In order to avoid an ugly error message at runtime (during IPL loading) we need
to truncate 'count' length according to max device/file size if reading from uncompressed gzip image in memory.
-rw-r--r--ipl/offset.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ipl/offset.c b/ipl/offset.c
index 6529620..31dd57a 100644
--- a/ipl/offset.c
+++ b/ipl/offset.c
@@ -20,11 +20,13 @@ static int offset_read(int fd, char *buf, unsigned count, unsigned devaddr)
{
struct offsets *o = &ofd[fd];
- if (Debug) printf("offset_read(%d, 0x%p, %d, %d)\r\n",
+ if (Debug) printf("offset_read(%d, 0x%p, %d, %d)\r\n",
fd, buf, count, devaddr);
- /* LATER -- truncate 'count' according to max device size */
- if (o->length > 0 && devaddr + count > o->length)
+ /* truncate 'count' according to max device/file size */
+ if (o->length > 0 && devaddr < o->length && devaddr + count > o->length)
+ count = o->length - devaddr;
+ else if (o->length > 0 && devaddr + count > o->length)
{
printf("offset_read(%d, 0x%p, %d, %d) can't seek past %d\r\n",
fd, buf, count, devaddr, o->length);