8c6b1ac71e
Also include some minor fixes for gcc 5.1.1 Signed-off-by: Peter Jones <pjones@redhat.com>
48 lines
1.4 KiB
Diff
48 lines
1.4 KiB
Diff
From af435524cd39f0967cd46e650e4312ecfeb158ed Mon Sep 17 00:00:00 2001
|
|
From: Vladimir Serbinenko <phcoder@gmail.com>
|
|
Date: Tue, 20 Jan 2015 12:58:17 +0100
|
|
Subject: [PATCH 139/506] grub_fshelp_read_file: Don't attempt to read past the
|
|
end of file.
|
|
|
|
---
|
|
ChangeLog | 5 +++++
|
|
grub-core/fs/fshelp.c | 7 +++++++
|
|
2 files changed, 12 insertions(+)
|
|
|
|
diff --git a/ChangeLog b/ChangeLog
|
|
index 80ef35c..c18ab2d 100644
|
|
--- a/ChangeLog
|
|
+++ b/ChangeLog
|
|
@@ -1,5 +1,10 @@
|
|
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
|
+ * grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read
|
|
+ past the end of file.
|
|
+
|
|
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
|
+
|
|
* grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len
|
|
synchronously with line.
|
|
|
|
diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c
|
|
index 42bd542..b899bed 100644
|
|
--- a/grub-core/fs/fshelp.c
|
|
+++ b/grub-core/fs/fshelp.c
|
|
@@ -252,6 +252,13 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
|
|
grub_disk_addr_t i, blockcnt;
|
|
int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
|
|
|
|
+ if (pos > filesize)
|
|
+ {
|
|
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
|
|
+ N_("attempt to read past the end of file"));
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
/* Adjust LEN so it we can't read past the end of the file. */
|
|
if (pos + len > filesize)
|
|
len = filesize - pos;
|
|
--
|
|
2.4.3
|
|
|