From 58db62c4e754df555386c73b5e8f6f6849f1dbb3 Mon Sep 17 00:00:00 2001
From: Robert Hensing <robert@roberthensing.nl>
Date: Fri, 1 Oct 2021 12:17:26 +0200
Subject: [PATCH] rel2abs: Only call getcwd_real for relative paths

---
 src/rel2abs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/rel2abs.c b/src/rel2abs.c
index f8c27af9..899953a2 100644
--- a/src/rel2abs.c
+++ b/src/rel2abs.c
@@ -46,13 +46,13 @@ LOCAL char * rel2abs(const char * name, char * resolved)
         goto end;
     }
 
-    getcwd_real(cwd, FAKECHROOT_PATH_MAX - 1);
-    narrow_chroot_path(cwd);
-
     if (*name == '/') {
         strlcpy(resolved, name, FAKECHROOT_PATH_MAX);
     }
     else {
+        getcwd_real(cwd, FAKECHROOT_PATH_MAX - 1);
+        narrow_chroot_path(cwd);
+
         snprintf(resolved, FAKECHROOT_PATH_MAX, "%s/%s", cwd, name);
     }
 
