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 2AAF13858435 for ; Fri, 28 Oct 2022 05:35:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AAF13858435 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=1666935299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UHKWVGWkpVgc/8H0HCMOCpxyX+vBVYaErbwMrLTrP3U=; b=WYJxziFVl1ch90Ds09ocT2FUNRX0Q2QsjbjToWv7BJnh20IF+V557irPHc9GB+1VNAbmzO l5/MMqS4Sad2M95nyCgSFaP1PeeT7gcUqrpFRc6vET+B4TLJKH77njhLP8J/V06KJDOCz1 YXbEeyzvyjnxYPFnm3ksPURjY2MIn5s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-542-goX-Us21OiGkODqUNPzB1g-1; Fri, 28 Oct 2022 01:34:55 -0400 X-MC-Unique: goX-Us21OiGkODqUNPzB1g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A519E811E75; Fri, 28 Oct 2022 05:34:55 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34C40492B1E; Fri, 28 Oct 2022 05:34:55 +0000 (UTC) From: Florian Weimer To: Szabolcs Nagy via Libc-alpha Cc: Szabolcs Nagy Subject: Re: [PATCH 05/20] Fix invalid pointer dereference in wcscpy_chk References: <8a778b8eecc1ad9d782884291965864ea5c20ef7.1666877952.git.szabolcs.nagy@arm.com> Date: Fri, 28 Oct 2022 07:34:53 +0200 In-Reply-To: <8a778b8eecc1ad9d782884291965864ea5c20ef7.1666877952.git.szabolcs.nagy@arm.com> (Szabolcs Nagy via Libc-alpha's message of "Thu, 27 Oct 2022 16:32:30 +0100") Message-ID: <87czacik8y.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.8 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Szabolcs Nagy via Libc-alpha: > The src pointer is const and points to a different object, so accessing > dest via src is invalid. > --- > debug/wcscpy_chk.c | 34 +++++++--------------------------- > 1 file changed, 7 insertions(+), 27 deletions(-) > > diff --git a/debug/wcscpy_chk.c b/debug/wcscpy_chk.c > index 8ef03f81e4..d2dc769181 100644 > --- a/debug/wcscpy_chk.c > +++ b/debug/wcscpy_chk.c > @@ -24,36 +24,16 @@ wchar_t * > __wcscpy_chk (wchar_t *dest, const wchar_t *src, size_t n) > { > wint_t c; > + wchar_t *wcp = dest; > > + do > { > + if (__glibc_unlikely (n-- == 0)) > + __chk_fail (); > + c = *src++; > + *wcp++ = c; > } > + while (c != L'\0'); > > return dest; > } Seems fine. Reviewed-by: Florian Weimer Thanks, Florian