From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id CF25738515D9 for ; Wed, 26 Jan 2022 12:14:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF25738515D9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643199273; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=GtTx7hKU1D5wXT9vBgoLsO1nd0v5XKbTrrSHxaaFrAY=; b=WPnkWjxXvz2MHlrV46ZWrcgDVecvzw2F8Xn01qt9J5OYVtwlEbKUr4PttG4XLS4IdhoU4X mu3x6fFd2HUPc7pafGXPsMWTS3y9UrlUSnRfBlSeB09e59+YYgm+424QoO92qNSATf/1FJ TU6CP6agk0L1IOdE4P0qkwhkW48lp4s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-FNjt59_xMC2WO1yhn8Stbw-1; Wed, 26 Jan 2022 07:14:32 -0500 X-MC-Unique: FNjt59_xMC2WO1yhn8Stbw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74DCA363A5 for ; Wed, 26 Jan 2022 12:14:31 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-112-15.ams2.redhat.com [10.36.112.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45222106C085 for ; Wed, 26 Jan 2022 12:14:31 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id B41FFA810A5; Wed, 26 Jan 2022 13:14:29 +0100 (CET) Date: Wed, 26 Jan 2022 13:14:29 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH 1/1] Fix null-pointer dereference in nano-malloc Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20220125154410.56045-1-yaredcyril@gmail.com> <20220125154410.56045-2-yaredcyril@gmail.com> MIME-Version: 1.0 In-Reply-To: <20220125154410.56045-2-yaredcyril@gmail.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vinschen@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2022 12:14:34 -0000 On Jan 25 07:44, Cyril Yared wrote: > If p is NULL, then the free_list is empty and we should return the > correct failure values. > --- > newlib/libc/stdlib/nano-mallocr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/newlib/libc/stdlib/nano-mallocr.c b/newlib/libc/stdlib/nano-mallocr.c > index 6fb08a616..0c5fb2885 100644 > --- a/newlib/libc/stdlib/nano-mallocr.c > +++ b/newlib/libc/stdlib/nano-mallocr.c > @@ -322,7 +322,7 @@ void * nano_malloc(RARG malloc_size_t s) > r=r->next; > } > > - if ((char *)p + p->size == (char *)_SBRK_R(RCALL 0)) > + if (p != NULL && (char *)p + p->size == (char *)_SBRK_R(RCALL 0)) > { > /* The last free item has the heap end as neighbour. > * Let's ask for a smaller amount and merge */ > -- > 2.21.0 (Apple Git-122.2) Pushed. Thanks, Corinna