* [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow
@ 2011-11-08 9:21 Gabe Black
2011-11-08 13:48 ` Mike Frysinger
2011-11-12 10:22 ` Graeme Russ
0 siblings, 2 replies; 5+ messages in thread
From: Gabe Black @ 2011-11-08 9:21 UTC (permalink / raw)
To: u-boot
printf as currently implemented in u-boot has a problem where it can
overflow an internal buffer if it prints an expanded string that's too
long. Our command lines are long enough to cause this problem. A fix
should be coming, but in the mean time this change replaces a problematic
printf with a few calls to puts that have the same effect. This may perform
slightly better because it should avoid a copy and scanning for format
specifiers. The amount of time it actually takes up is very tiny relative
to everything else so in practice that's probably irrelevant.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
arch/x86/lib/zimage.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index d2dd6fd..a48ae6c 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -78,7 +78,9 @@ static void build_command_line(char *command_line, int auto_boot)
}
- printf("Kernel command line: \"%s\"\n", command_line);
+ puts("Kernel command line: \"");
+ puts(command_line);
+ puts("\"\n");
}
void *load_zimage(char *image, unsigned long kernel_size,
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow
2011-11-08 9:21 [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow Gabe Black
@ 2011-11-08 13:48 ` Mike Frysinger
2011-11-12 10:22 ` Graeme Russ
1 sibling, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2011-11-08 13:48 UTC (permalink / raw)
To: u-boot
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111108/bddbd63b/attachment.pgp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow
2011-11-08 9:21 [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow Gabe Black
2011-11-08 13:48 ` Mike Frysinger
@ 2011-11-12 10:22 ` Graeme Russ
2011-11-13 2:02 ` [U-Boot] [PATCH v2] x86: " Gabe Black
1 sibling, 1 reply; 5+ messages in thread
From: Graeme Russ @ 2011-11-12 10:22 UTC (permalink / raw)
To: u-boot
Hi Gabe,
On 08/11/11 20:21, Gabe Black wrote:
> printf as currently implemented in u-boot has a problem where it can
> overflow an internal buffer if it prints an expanded string that's too
> long. Our command lines are long enough to cause this problem. A fix
> should be coming, but in the mean time this change replaces a problematic
> printf with a few calls to puts that have the same effect. This may perform
> slightly better because it should avoid a copy and scanning for format
> specifiers. The amount of time it actually takes up is very tiny relative
> to everything else so in practice that's probably irrelevant.
>
> Signed-off-by: Gabe Black <gabeblack@chromium.org>
> ---
> arch/x86/lib/zimage.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
Can you please rebase against u-boot-x86/master and re-submit
While you're at it, please change tag to 'x86:' style
Thanks,
Graeme
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] x86: Change printf to puts to avoid a buffer overflow
2011-11-12 10:22 ` Graeme Russ
@ 2011-11-13 2:02 ` Gabe Black
2011-11-13 11:43 ` Graeme Russ
0 siblings, 1 reply; 5+ messages in thread
From: Gabe Black @ 2011-11-13 2:02 UTC (permalink / raw)
To: u-boot
printf as currently implemented in u-boot has a problem where it can
overflow an internal buffer if it prints an expanded string that's too
long. Our command lines are long enough to cause this problem. A fix
should be coming, but in the mean time this change replaces a problematic
printf with a few calls to puts that have the same effect. This may perform
slightly better because it should avoid a copy and scanning for format
specifiers. The amount of time it actually takes up is very tiny relative
to everything else so in practice that's probably irrelevant.
Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
Changes in v2:
- Rebase onto the x86 repository.
- Change the style of the summary tag.
arch/x86/lib/zimage.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 8b42b5c..6843ff6 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -75,7 +75,9 @@ static void build_command_line(char *command_line, int auto_boot)
if (env_command_line)
strcat(command_line, env_command_line);
- printf("Kernel command line: \"%s\"\n", command_line);
+ puts("Kernel command line: \"");
+ puts(command_line);
+ puts("\"\n");
}
void *load_zimage(char *image, unsigned long kernel_size,
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] x86: Change printf to puts to avoid a buffer overflow
2011-11-13 2:02 ` [U-Boot] [PATCH v2] x86: " Gabe Black
@ 2011-11-13 11:43 ` Graeme Russ
0 siblings, 0 replies; 5+ messages in thread
From: Graeme Russ @ 2011-11-13 11:43 UTC (permalink / raw)
To: u-boot
On 13/11/11 13:02, Gabe Black wrote:
> printf as currently implemented in u-boot has a problem where it can
> overflow an internal buffer if it prints an expanded string that's too
> long. Our command lines are long enough to cause this problem. A fix
> should be coming, but in the mean time this change replaces a problematic
> printf with a few calls to puts that have the same effect. This may perform
> slightly better because it should avoid a copy and scanning for format
> specifiers. The amount of time it actually takes up is very tiny relative
> to everything else so in practice that's probably irrelevant.
>
> Signed-off-by: Gabe Black <gabeblack@chromium.org>
Applied to u-boot-x86/master
Thanks,
Graeme
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-13 11:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 9:21 [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow Gabe Black
2011-11-08 13:48 ` Mike Frysinger
2011-11-12 10:22 ` Graeme Russ
2011-11-13 2:02 ` [U-Boot] [PATCH v2] x86: " Gabe Black
2011-11-13 11:43 ` Graeme Russ
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox