From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Sat, 16 Feb 2008 02:59:32 -0500 Subject: [U-Boot-Users] [rfc] warning about overlapping regions when booting with bootm Message-ID: <200802160259.32371.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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