From c23d17095db0611d8ee32357f17da441bcb0bc75 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 23 Nov 2014 19:15:21 +0100 Subject: utils: 'elf-file?' and 'ar-file?' return #f for directories. This avoids uncaught exceptions when the 'strip' phase would call these procedures on symlinks to directories, such as 'lib/terminfo' in ncurses (see .) * guix/build/utils.scm (file-header-match): Catch 'system-error', and return #f upon EISDIR. --- guix/build/utils.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'guix/build') diff --git a/guix/build/utils.scm b/guix/build/utils.scm index a3050b955c..c480dbf8a6 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -122,7 +122,13 @@ with the bytes in HEADER, a bytevector." (get-bytevector-n port len)) #:binary #t #:guess-encoding #f)) - (equal? (get-header) header))) + (catch 'system-error + (lambda () + (equal? (get-header) header)) + (lambda args + (if (= EISDIR (system-error-errno args)) + #f ;FILE is a directory + (apply throw args)))))) (define %elf-magic-bytes ;; Magic bytes of ELF files. See . -- cgit v1.2.3