Blame SOURCES/tar-1.30-xgetcwd-null-return-check.patch

4b8952
From 60acf5a7407ef263aaf7d3751da08167b1990eb0 Mon Sep 17 00:00:00 2001
4b8952
From: Sergey Poznyakoff <gray@gnu.org>
4b8952
Date: Wed, 20 May 2020 13:35:28 +0200
4b8952
Subject: [PATCH] Check return value from xgetcwd
4b8952
4b8952
* src/misc.c (chdir_arg,tar_getcdpath): Check for non-NULL
4b8952
return from xgetcwd. The function returns NULL for any
4b8952
error originating from getcwd.
4b8952
---
4b8952
 src/misc.c | 10 +++++++---
4b8952
 1 file changed, 7 insertions(+), 3 deletions(-)
4b8952
4b8952
diff --git a/src/misc.c b/src/misc.c
4b8952
index cd07f53..eccf6f9 100644
4b8952
--- a/src/misc.c
4b8952
+++ b/src/misc.c
4b8952
@@ -301,8 +301,6 @@ normalize_filename (int cdidx, const char *name)
4b8952
       size_t copylen;
4b8952
       bool need_separator;
4b8952
 
4b8952
-      if (!cdpath)
4b8952
-	call_arg_fatal ("getcwd", ".");
4b8952
       copylen = strlen (cdpath);
4b8952
       need_separator = ! (DOUBLE_SLASH_IS_DISTINCT_ROOT
4b8952
 			  && copylen == 2 && ISSLASH (cdpath[1]));
4b8952
@@ -909,6 +907,8 @@ chdir_arg (char const *dir)
4b8952
 	{
4b8952
 	  wd[wd_count].name = ".";
4b8952
 	  wd[wd_count].abspath = xgetcwd ();
4b8952
+    if (!wd[wd_count].abspath)
4b8952
+	    call_arg_fatal ("getcwd", ".");
4b8952
 	  wd[wd_count].fd = AT_FDCWD;
4b8952
 	  wd_count++;
4b8952
 	}
4b8952
@@ -1034,7 +1034,11 @@ tar_getcdpath (int idx)
4b8952
     {
4b8952
       static char *cwd;
4b8952
       if (!cwd)
4b8952
-	cwd = xgetcwd ();
4b8952
+	      {
4b8952
+          cwd = xgetcwd ();
4b8952
+          if (!cwd)
4b8952
+            call_arg_fatal ("getcwd", ".");
4b8952
+	      }
4b8952
       return cwd;
4b8952
     }
4b8952
   return wd[idx].abspath;
4b8952
-- 
4b8952
2.24.1
4b8952