From patchwork Sat Jan 1 17:51:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Linderud X-Patchwork-Id: 2001 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.25) for (single-drop); Sat, 01 Jan 2022 17:51:59 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id 6Jq/F7+U0GHymwcAK+/4rw (envelope-from ) for ; Sat, 01 Jan 2022 17:51:59 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 203B8BD5579; Sat, 1 Jan 2022 17:51:58 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id EE5B0B5D259; Sat, 1 Jan 2022 17:51:57 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.archlinux.org (mail.archlinux.org [95.216.189.61]) by lists.archlinux.org (Postfix) with ESMTPS id 9729DB5D24B for ; Sat, 1 Jan 2022 17:51:56 +0000 (UTC) From: Morten Linderud DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-rsa; t=1641059516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3sr1HB8Q893od9jW4ysbogzHgZ6gKNxp5Z1P6/j4rgE=; b=skJPSzOUblX+2L/WPKGE60TWqXpB0s3bHwyitflJa71StkT5jgueJ0eNuggBhnsl+KhFWT Gdro96cm4wEn96vU+5idMQvRHkAN4VFnlGBZ0UljKDbRpjRwgAhO4W5kAG/r2DfggRv/K0 d/23jCIBbQu9aNmy16KMtILRP2rNAkIDbZqrUrz8nJ1qNdExmC30dad6l47rXb8lPOhhB4 OCgPjOQ1RzSiXKxZmka6LRRFF2TxHtkgLP5cEHDK07Q3IbFkbmHkqZkVgYv1qjE98Q2St2 mTGixwLRRG3AZ2U8J+ZkyO9TJL0JjPXX+oFbUgi4OCzRVLve0j3Po8gGgAvbYzofKvbWko qVkuA6Rq3u6VM4ZAezLAxGX7GZCE94dGp7Ow3ZO+Csj5lr2vUnq9aK3oeaydciemBsrqOB oQMwUxGnbcFc/6jcEHbH23aUnI2G+0wnMqGnpV/KEBFY9QWWw6a3y2SNf+sB6IHXG6ZxL9 6TzIm4jbTRhQk2ZsdpdwLmZmiEknDeQ9G7pO1nD+XgKTkPq3pC52HMukBJEPHVnrReUVRq jCJmmIEs5uUi9vwS5hLHLF9C59mpYB2iHYQblP6gvXmMbTUaRJVFg/WiLUf9JHI/bwJai7 wGI0vXIMLu3QA9xBHvDcUx6TBFeTdMEXqtb7E2oXb2pdT6Ce5kTuI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-ed25519; t=1641059516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3sr1HB8Q893od9jW4ysbogzHgZ6gKNxp5Z1P6/j4rgE=; b=fmKgEiABpbpUeSmJKDsz4YGpCLXWXuU7C/zJVO1eVj/MJBYQZdjQtbNqaZOkhL+HhA41BS ZFuqPZOrvg+RGuDw== To: pacman-dev@lists.archlinux.org Cc: Morten Linderud Subject: [PATCH] makepkg: Handle invalid files in strip Date: Sat, 1 Jan 2022 18:51:53 +0100 Message-Id: <20220101175153.1441024-1-foxboron@archlinux.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=archlinux.org header.s=dkim-rsa header.b=skJPSzOU; dkim=pass header.d=archlinux.org header.s=dkim-ed25519 header.b=fmKgEiAB; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 203B8BD5579 X-Spamd-Result: default: False [-2.61 / 15.00]; DWL_DNSWL_MED(-2.00)[archlinux.org:dkim]; MID_CONTAINS_FROM(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; R_MISSING_CHARSET(0.50)[]; RCVD_IN_DNSWL_MED(-0.40)[2a01:4f9:c010:9eb4::1:from,95.216.189.61:received]; MAILLIST(-0.20)[mailman]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; R_DKIM_ALLOW(-0.20)[archlinux.org:s=dkim-rsa,archlinux.org:s=dkim-ed25519]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; DKIM_TRACE(0.00)[archlinux.org:+]; RCVD_COUNT_THREE(0.00)[3]; FROM_NEQ_ENVFROM(0.00)[foxboron@archlinux.org,pacman-dev-bounces@lists.archlinux.org]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org From: Morten Linderud makepkg does a fairly naive pass on the DWARF files to generate source files. If this is done on things like Golang it will give strip a list of files that are truncated paths or completely invalid virtual paths for the runtime to interpret. We also explicitly only allow source files that contains the given debug source directory. We depend on this for file lookup and it would produce invalid packages with weird paths if they are not present. Signed-off-by: Morten Linderud --- scripts/libmakepkg/tidy/strip.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 92a6fb15..d9eb8a95 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -60,11 +60,11 @@ strip_file() { while IFS= read -r t; do file=${t/${dbgsrcdir}/"$srcdir"} dest="${dbgsrc/"$dbgsrcdir"/}$t" - if ! [[ -f $dest ]]; then + if [[ -f "$file" ]] && ! [[ -f $dest ]]; then mkdir -p "${dest%/*}" cp -- "$file" "$dest" fi - done < <(source_files "$binary") + done < <(source_files "$binary" | grep "$dbgsrcdir") # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}"