From patchwork Thu Oct 21 09:24:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kostaras Nikolaos X-Patchwork-Id: 71914 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 17485136320 for ; Thu, 21 Oct 2010 11:26:50 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id ECB4C348C9D1 for ; Thu, 21 Oct 2010 11:26:49 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Thu, 21 Oct 2010 11:26:49 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Thu, 21 Oct 2010 11:25:25 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Thu, 21 Oct 2010 11:25:24 +0200 Received: from scanner-1.m-online.net (scanner-1.mail.m-online.net [192.168.8.165]) by mail.m-online.net (Postfix) with ESMTP id C02A91C00142; Thu, 21 Oct 2010 11:25:24 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-1.m-online.net (Postfix) with ESMTP id 4685146C0B9; Thu, 21 Oct 2010 11:25:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B9AA280E7; Thu, 21 Oct 2010 11:25:12 +0200 (CEST) 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 Mq2O-YZrsT6x; Thu, 21 Oct 2010 11:25:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B1F50280B8; Thu, 21 Oct 2010 11:25:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21A40280AB for ; Thu, 21 Oct 2010 11:25:02 +0200 (CEST) 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 G3B3VYgr+dSH for ; Thu, 21 Oct 2010 11:25:00 +0200 (CEST) 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 dfsrvmailgw.intracomdefense.com (dfsrvmailgw.intracomdefense.com [194.24.170.2]) by theia.denx.de (Postfix) with ESMTP id 07140280AA for ; Thu, 21 Oct 2010 11:24:57 +0200 (CEST) Received: from DFSRVMAIL.intracomdefense.com (unverified) by dfsrvmailgw.intracomdefense.com (Mail Gateway) with ESMTP id for ; Thu, 21 Oct 2010 12:27:40 +0300 Received: from [172.18.5.120] ([172.18.5.120]) by DFSRVMAIL.intracomdefense.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 21 Oct 2010 12:28:14 +0300 Message-ID: <4CC006B1.8000905@intracomdefense.com> Date: Thu, 21 Oct 2010 12:24:01 +0300 From: Kostaras Nikolaos User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: u-boot@lists.denx.de X-OriginalArrivalTime: 21 Oct 2010 09:28:14.0601 (UTC) FILETIME=[496DFF90:01CB7102] Subject: [U-Boot] [PATCH] Prevent malloc with size 0 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net In case malloc is invoked with requested size 0, this patch will prevent the execution of the allocation algorithm (because it corrupts the data structures) and will return 0 to the caller. Signed-off-by: Nikolaos Kostaras --- common/dlmalloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) -- 1.6.4.4 diff --git a/common/dlmalloc.c b/common/dlmalloc.c index fce7a76..d9e3ea9 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -2182,7 +2182,7 @@ Void_t* mALLOc(bytes) size_t bytes; return 0; } - if ((long)bytes < 0) return 0; + if ((long)bytes <= 0) return 0; nb = request2size(bytes); /* padded request size; */