public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [rfc] warning about overlapping regions when booting with bootm
@ 2008-02-16  7:59 Mike Frysinger
  2008-02-16 23:06 ` Wolfgang Denk
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-02-16  7:59 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-22 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16  7:59 [U-Boot-Users] [rfc] warning about overlapping regions when booting with bootm Mike Frysinger
2008-02-16 23:06 ` Wolfgang Denk
2008-02-16 23:19   ` Mike Frysinger
2008-02-17 20:29   ` [U-Boot-Users] [rfc] warning about overlapping regions whenbooting " Robin Getz
2008-02-17 22:09     ` Wolfgang Denk
2008-02-17 22:55       ` Robin Getz
2008-02-22 17:49       ` Marian Balakowicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox