we semi-frequently get users who try to boot an image on top of itself and
when when things crash, dont realize why.  i put together this quick little
warning, but i'm guessing that Wolfgang's answer is "don't bloat the code for
stupid people" ...

--- common/cmd_bootm.c
+++ common/cmd_bootm.c
@@ -1434,6 +1439,16 @@ int gunzip(void *dst, int dstlen, unsign
        z_stream s;
        int r, i, flags;
 
+       /* If memory regions overlap, whine about it.  We cannot check
+        * the dstlen value as it is usually set to the max possible value
+        * (CFG_BOOTM_LEN) which can be huge (64M).  Instead, we'll assume
+        * the decompression size will be at least as big as the compressed
+        * size so that we can at least check part of the destination.
+        */
+       if ((dst <= (void *)src && (void *)src < dst + /*dstlen*/ *lenp) ||
+           (dst <= (void *)(src + *lenp) && (void *)(src + *lenp) < dst + 
/*dstlen*/ *lenp))
+               puts ("\n   Warning: src and dst regions overlap ... ");
+
        /* skip header */
        i = 10;
        flags = src[3];
-mike

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to