public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Buffer overflow in print_data() in ft_build.c
@ 2006-10-09 10:26 Fredrik Roubert
  2006-10-09 10:51 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Fredrik Roubert @ 2006-10-09 10:26 UTC (permalink / raw)
  To: u-boot

Hi!

In print_data() in ft_build.c, printf() is used to print strings of
arbitrary length from the device tree, which will cause a buffer
overflow that crashes U-Boot if any of these strings is longer than
CFG_PBSIZE.

(I encountered this while debugging my flat device tree while having a
very long kernel parameter line.)

The attached patch changes print_data() to use puts() instead, which
doesn't have the buffer overflow problem.

Cheers // Fredrik Roubert

-- 
Visserij 192  |  +32 473 344527 / +46 708 776974
BE-9000 Gent  |  http://www.df.lth.se/~roubert/
-------------- next part --------------
diff -ur u-boot-2006-06-30-2020.orig/common/ft_build.c u-boot-2006-06-30-2020/common/ft_build.c
--- u-boot-2006-06-30-2020.orig/common/ft_build.c	2006-06-30 20:16:37.000000000 +0200
+++ u-boot-2006-06-30-2020/common/ft_build.c	2006-10-09 12:12:56.000000000 +0200
@@ -293,7 +293,9 @@
 		return;
 
 	if (is_printable_string(data, len)) {
-		printf(" = \"%s\"", (char *)data);
+		puts(" = \"");
+		puts(data);
+		puts("\"");
 		return;
 	}
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 303 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20061009/2368dc96/attachment.pgp 

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

* [U-Boot-Users] Buffer overflow in print_data() in ft_build.c
  2006-10-09 10:26 [U-Boot-Users] Buffer overflow in print_data() in ft_build.c Fredrik Roubert
@ 2006-10-09 10:51 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2006-10-09 10:51 UTC (permalink / raw)
  To: u-boot

In message <20061009102605.GA4171@igloo.df.lth.se> you wrote:
> 
> The attached patch changes print_data() to use puts() instead, which
> doesn't have the buffer overflow problem.

Applied, thanks. But please provide a proper CHANGELOG entry next
time.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Puritan is someone who is deathly afraid that  someone,  somewhere,
is having fun.

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

end of thread, other threads:[~2006-10-09 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-09 10:26 [U-Boot-Users] Buffer overflow in print_data() in ft_build.c Fredrik Roubert
2006-10-09 10:51 ` Wolfgang Denk

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