debug-link: Protect against dangling symlinks.

Fixes <https://issues.guix.gnu.org/60584>.
Reported by Greg Hogan <code@greghogan.com>
and Sébastien Rey-Coyrehourcq <sebastien.rey-coyrehourcq@univ-rouen.fr>.

* guix/build/debug-link.scm (find-elf-files): Wrap 'elf-file?' call in 'catch'.
This commit is contained in:
Ludovic Courtès 2023-01-17 11:22:36 +01:00
parent 79b11cafcf
commit c4a8762e52
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@ -175,7 +175,15 @@ directories."
outputs))
(append-map (lambda (directory)
(filter elf-file?
(filter (lambda (file)
(catch 'system-error
(lambda ()
(elf-file? file))
(lambda args
;; FILE might be a dangling symlink.
(if (= ENOENT (system-error-errno args))
#f
(apply throw args)))))
(with-error-to-port (%make-void-port "w")
(lambda ()
(find-files directory)))))