diff options
author | Helge Deller <deller@gmx.de> | 2022-08-05 10:44:56 +0200 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2022-08-05 10:44:56 +0200 |
commit | 0f8e7fe47e44751107ad3d343623c0faf0312983 (patch) | |
tree | 51eb66a4f5bdbb668ad317287a2bf2b861a7b4a8 | |
parent | 481730378db534d0816a68b4650864ad9db17f0f (diff) | |
download | palo-0f8e7fe47e44751107ad3d343623c0faf0312983.tar.gz |
ipl: Abort early if we know we will not reach the block
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r-- | ipl/offset.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ipl/offset.c b/ipl/offset.c index c048461..fb2a6ff 100644 --- a/ipl/offset.c +++ b/ipl/offset.c @@ -23,6 +23,13 @@ static int offset_read(int fd, char *buf, unsigned count, __u64 devaddr) if (Debug) printf("offset_read(%d, 0x%p, %d, %lld)\r\n", fd, buf, count, devaddr); + /* abort early if we reach firmware limit */ + if (disk_2gb_limit && ((devaddr + count) >> 31)) { + printf("offset_read(%lld): block not reachable via firmware call\r\n", + devaddr + count); + return -1; + } + /* truncate 'count' according to max device/file size */ if (o->length > 0 && devaddr < o->length && devaddr + count > o->length) count = o->length - devaddr; |