From patchwork Mon Oct 23 11:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1853658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=grHo8BS2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SDXX50XMDz202k for ; Mon, 23 Oct 2023 22:09:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 127CF385840B for ; Mon, 23 Oct 2023 11:09:39 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 3DF9A3858D37 for ; Mon, 23 Oct 2023 11:09:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DF9A3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3DF9A3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698059371; cv=none; b=Qox0ITLDD/GrEHSuEKXdMNYEkMBzX1Dk0yMXhD9idsUHHvN7WV/+J2EXMANdxmnMr0G2wafExbq+DRh7evPDS25NlBYu77aZXLd2P0pi7lQ1BpOn44mgunG/5PrpYoytIF87jS168gJyOyZO5ac7cpvGa+Mca1jV3TYJ/xgW9pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698059371; c=relaxed/simple; bh=ELnt9ba1VdB27dXDcg6NrQV8gNAHMUcMwCqyjycMXAg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=O2jjxLRRPxnOL1foPJjwZxGVh3A510L6lxK8zE/mExzdPRc17MmNDQpCE1rXJ3IlxqRnCBeMwYKOPEMh/eLOQJyIhX9xOWXneWSZiMAerGNbWPNdkU1eNye34wTA9x8kMK3etMTY0TN8eBmmyRLY9Mx+S0nFScrgEUpw21cXrp0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698059369; 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; bh=yoNkg2VZIuYzbRF2SaM7L92DXigq76lcruXn0hlbqH4=; b=grHo8BS202tntoC/BlHrhf29QR7fVx4hCHAkHuckH0gcHLM008imY2kynugES7ht/9PD1I TZb3VfFuboyJ9HDo+U1TCk9Vw/1X3Mh0AjtXTtXIoyd3P6AAIi7X2DWJlPeRVYihfkT99k HYOO6HsgfwdMMZF1eW4KurdXeki5HXE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-j8t3naVTNGySwRVDSbkO4Q-1; Mon, 23 Oct 2023 07:09:28 -0400 X-MC-Unique: j8t3naVTNGySwRVDSbkO4Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F92C802896; Mon, 23 Oct 2023 11:09:28 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D8772166B26; Mon, 23 Oct 2023 11:09:27 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Cc: Guillem Jover Subject: [PATCH] ldconfig: Actually ignore dpkg-related temporarily files Date: Mon, 23 Oct 2023 13:09:25 +0200 Message-ID: <87edhlwq6y.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 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_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org These files actually end in .dpkg-new and .dpkg-tmp, not .tmp as I mistakenly assumed. Fixes commit 2aa0974d2573441bffd59 ("elf: ldconfig should skip temporary files created by package managers"). --- elf/ldconfig.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) base-commit: 2aa0974d2573441bffd596b07bff8698b1f2f18c diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 02387a169c..4abde26e60 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -661,6 +661,17 @@ struct dlib_entry struct dlib_entry *next; }; +/* Return true if the N bytes at NAME end with with the characters in + the string SUFFIX. (NAME[N + 1] does not have to be a null byte.) + Expected to be called with a string literal for SUFFIX. */ +static inline bool +endswithn (const char *name, size_t n, const char *suffix) +{ + return (n >= strlen (suffix) + && memcmp (name + n - strlen (suffix), suffix, + strlen (suffix)) == 0); +} + /* Skip some temporary DSO files. These files may be partially written and lead to ldconfig crashes when examined. */ static bool @@ -670,8 +681,7 @@ skip_dso_based_on_name (const char *name, size_t len) names like these are never really DSOs we want to look at. */ if (len >= sizeof (".#prelink#") - 1) { - if (strcmp (name + len - sizeof (".#prelink#") + 1, - ".#prelink#") == 0) + if (endswithn (name, len, ".#prelink#")) return true; if (len >= sizeof (".#prelink#.XXXXXX") - 1 && memcmp (name + len - sizeof (".#prelink#.XXXXXX") @@ -682,7 +692,8 @@ skip_dso_based_on_name (const char *name, size_t len) if (memchr (name, len, ';') != NULL) return true; /* Skip temporary files created by dpkg. */ - if (len > 4 && memcmp (name + len - 4, ".tmp", 4) == 0) + if (endswithn (name, len, ".dpkg-new") + || endswithn (name, len, ".dpkg-tmp")) return true; return false; }