From patchwork Tue Nov 8 09:21:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabe Black X-Patchwork-Id: 124299 X-Patchwork-Delegate: graeme.russ@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5D5601007D4 for ; Tue, 8 Nov 2011 20:21:56 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 16A8729577; Tue, 8 Nov 2011 10:21:53 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pAFY30XNl0WS; Tue, 8 Nov 2011 10:21:52 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BBE3D292F9; Tue, 8 Nov 2011 10:21:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 760EC292F9 for ; Tue, 8 Nov 2011 10:21:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Njkn3PaWSKOx for ; Tue, 8 Nov 2011 10:21:49 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id B66E128B7E for ; Tue, 8 Nov 2011 10:21:47 +0100 (CET) Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id pA89LjNk001863; Tue, 8 Nov 2011 01:21:45 -0800 Received: from gabeblack.mtv.corp.google.com (gabeblack.mtv.corp.google.com [172.22.72.31]) by wpaz24.hot.corp.google.com with ESMTP id pA89LirN031446; Tue, 8 Nov 2011 01:21:44 -0800 Received: by gabeblack.mtv.corp.google.com (Postfix, from userid 134246) id DB8C020136C; Tue, 8 Nov 2011 01:21:43 -0800 (PST) From: Gabe Black To: U-Boot Mailing List Date: Tue, 8 Nov 2011 01:21:41 -0800 Message-Id: <1320744101-32666-1-git-send-email-gabeblack@chromium.org> X-Mailer: git-send-email 1.7.3.1 X-System-Of-Record: true Cc: Graeme Russ , None@google.com Subject: [U-Boot] [PATCH] [x86] [zboot] Change printf to puts to avoid a buffer overflow X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Acked-by: Mike Frysinger --- 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,