aboutsummaryrefslogtreecommitdiffstats
path: root/main/alpine-conf/0001-setup-apkcache-fix-infinite-loop-when-non-existing-d.patch
blob: ed3191d2b62e6c8f4cd812f136caa3c5ce1ef9a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From b0b109a06f1f890b8833c6afa38c357a084c65bc Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 19 Mar 2015 12:44:41 +0000
Subject: [PATCH] setup-apkcache: fix infinite loop when non-existing dir
 specified

to reproduce: setup-apkcache /ponies

ref #3976
---
 setup-apkcache.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup-apkcache.in b/setup-apkcache.in
index 0e578c8..5210d82 100644
--- a/setup-apkcache.in
+++ b/setup-apkcache.in
@@ -47,10 +47,10 @@ find_mount_point() {
 	fi
 
 	local dir="$1"
-	while ! [ -d "$dir" ]; do
+	while [ -n "$dir" ] && ! [ -d "$dir" ]; do
 		dir=${dir%/*}
 	done
-	local fs_id=$(stat -f -c %i "$dir")
+	local fs_id=$(stat -f -c %i "${dir:-/}")
 	local parent="${dir%/*}"
 	while [ -n "$dir" ] && [ "$(stat -f -c %i $parent/)" = "$fs_id" ]; do
 		dir=$parent
-- 
2.3.3