From 1869e3b886c4596fb4ce471dd08121401d207cfa Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 16 Jan 2025 19:09:00 +0100 Subject: [PATCH] find-debuginfo: Make return from do_file explicit Make all returns from do_file explicit so they don't implicitly return the result of the last command. Also make sure the $temp/linked file exists, even if it is empty. A file could have hardlinks to files not under the buildroot. https://bugzilla.redhat.com/show_bug.cgi?id=2334760 Signed-off-by: Mark Wielaard --- scripts/find-debuginfo.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in index a360bf0582dc..d102e8937775 100755 --- a/scripts/find-debuginfo.in +++ b/scripts/find-debuginfo.in @@ -434,6 +434,7 @@ trap 'rm -rf "$temp"' EXIT # Build a list of unstripped ELF files and their hardlinks touch "$temp/primary" +touch "$temp/linked" find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \ \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \ -print | LC_ALL=C sort | @@ -458,7 +459,7 @@ do_file() local nlinks=$1 inum=$2 f=$3 id link linked get_debugfn "$f" - [ -f "${debugfn}" ] && return + [ -f "${debugfn}" ] && return 0 $verbose && echo "extracting debug info from $f" # See also cpio SOURCEFILE copy. Directories must match up. @@ -475,7 +476,7 @@ do_file() id=$(debugedit -b "$debug_base_name" -d "$debug_dest_name" \ $no_recompute -i \ ${build_id_seed:+--build-id-seed="$build_id_seed"} \ - -l "$SOURCEFILE" "$f") || exit + -l "$SOURCEFILE" "$f") || return 1 if [ -z "$id" ]; then echo >&2 "*** ${strict_error}: No build ID note found in $f" $strict && return 2 @@ -503,7 +504,7 @@ do_file() # just has its file names collected and adjusted. case "$dn" in /usr/lib/debug/*) - return ;; + return 0 ;; esac mkdir -p "${debugdn}" @@ -544,6 +545,8 @@ do_file() mkdir -p "$(dirname "$debugfn")" && ln -nf "$link" "$debugfn" done fi + + return 0 } # 16^6 - 1 or about 16 million files -- 2.47.1