[new uImage] Return error on image move/uncompress overwrites
Check for overwrites during image move/uncompress, return with error
when the original image gets corrupted. Report clear message to the user
and prevent further troubles when pointer to the corrupted images is passed
to do_bootm_linux routine.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
diff --git a/lib_ppc/ppc_linux.c b/lib_ppc/ppc_linux.c
index 0a625fc..3911687 100644
--- a/lib_ppc/ppc_linux.c
+++ b/lib_ppc/ppc_linux.c
@@ -23,6 +23,8 @@
* MA 02111-1307 USA
*/
+#define DEBUG
+
#include <common.h>
#include <watchdog.h>
#include <command.h>
@@ -259,11 +261,19 @@
of_data = (ulong)of_flat_tree;
#endif
} else if (image_check_magic (fdt_hdr)) {
+ ulong image_start, image_end;
+ ulong load_start, load_end;
+
printf ("## Flat Device Tree at %08lX\n", fdt_hdr);
print_image_hdr (fdt_hdr);
- if ((image_get_load (fdt_hdr) < image_get_image_end (fdt_hdr)) &&
- ((image_get_load (fdt_hdr) + image_get_data_size (fdt_hdr)) > (unsigned long)fdt_hdr)) {
+ image_start = (ulong)fdt_hdr;
+ image_end = image_get_image_end (fdt_hdr);
+
+ load_start = image_get_load (fdt_hdr);
+ load_end = load_start + image_get_data_size (fdt_hdr);
+
+ if ((load_start < image_end) && (load_end > image_start)) {
puts ("ERROR: fdt overwritten - "
"must RESET the board to recover.\n");
do_reset (cmdtp, flag, argc, argv);