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.129.124]) by sourceware.org (Postfix) with ESMTPS id 756EA3858D37 for ; Tue, 1 Nov 2022 23:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 756EA3858D37 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=1667346962; 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: content-transfer-encoding:content-transfer-encoding; bh=r1j2Uh2eDpQyeXsaJJYQqm9SzysiBTc0d117XNa+/qY=; b=FqsztFgPszsbeiQb+6OMSxiy7vTczPNl7H5llya7G11GZ9R11fC1elp8PdkFLmamXr6sxz co4tO3+BwZXuivTBj+sT0aMIp7NEXXaq2IntS/w/KE7oWk11/gtAdxx2uy5awGWbz1/zl0 XpnT9sqWyrFBOxkIe5Df7gWlIVlCK9E= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-plfiURkMObm14zGHT6jVOA-1; Tue, 01 Nov 2022 19:56:01 -0400 X-MC-Unique: plfiURkMObm14zGHT6jVOA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DF0511C05AB0 for ; Tue, 1 Nov 2022 23:56:00 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.33.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72F3111DCE7; Tue, 1 Nov 2022 23:56:00 +0000 (UTC) From: Aaron Merey To: elfutils-devel@sourceware.org Cc: Aaron Merey Subject: [PATCH OB] debuginfod-client: Fix out-of-bounds write Date: Tue, 1 Nov 2022 19:55:59 -0400 Message-Id: <20221101235559.63675-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 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: Pushed as obvious. Return early from path_escape when '\0' is seen in order to prevent an out-of-bounds write to the dest buffer. Signed-off-by: Aaron Merey --- debuginfod/debuginfod-client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index d097ca49..0c4a00cf 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -595,8 +595,7 @@ path_escape (const char *src, char *dest) { case '\0': dest[q] = '\0'; - q = PATH_MAX-1; /* escape for loop too */ - break; + return; case '/': /* escape / to prevent dir escape */ dest[q++]='#'; dest[q++]='#'; -- 2.37.3