Hello,

attached is a patch fixing bugs of run_in_dir () which I encountered while 
doing backport of #19593 for stable findutils.  Thanks in advance for 
considering the patch!

Kamil
diff --git a/lib/dircallback.c b/lib/dircallback.c
index 8497bee..ed36ee2 100644
--- a/lib/dircallback.c
+++ b/lib/dircallback.c
@@ -37,7 +37,7 @@ int
 run_in_dir (const struct saved_cwd *there,
 	    int (*callback)(void*), void *usercontext)
 {
-  int err, saved_errno;
+  int err = -1, saved_errno;
   struct saved_cwd here;
   if (0 == save_cwd (&here))
     {
@@ -50,6 +50,10 @@ run_in_dir (const struct saved_cwd *there,
 	{
 	  openat_restore_fail (errno);
 	}
+
+      if (restore_cwd (&here) != 0)
+	openat_restore_fail (errno);
+
       free_cwd (&here);
     }
   else

Reply via email to