coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: fix false failure with ASAN in rm-readdir-fail


From: Pádraig Brady
Subject: [PATCH] tests: fix false failure with ASAN in rm-readdir-fail
Date: Thu, 24 Nov 2016 01:32:25 +0000

* tests/rm/rm-readdir-fail.sh: ASAN correctly indicated
that fts was writing to freed memory.  This was because
we reused a single dirent in our readdir() test wrapper.
Since fts was deallocating those dirents, we now get
a new dirent for each call to our readdir wrapper.
---
 tests/rm/rm-readdir-fail.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/rm/rm-readdir-fail.sh b/tests/rm/rm-readdir-fail.sh
index 835d342..91fb0f6 100755
--- a/tests/rm/rm-readdir-fail.sh
+++ b/tests/rm/rm-readdir-fail.sh
@@ -47,8 +47,8 @@ struct dirent *readdir (DIR *dirp)
       errno = ESRCH;
       return NULL;
     }
-  static struct dirent* d;
-  if (! d && ! ( d = real_readdir (dirp)))
+  struct dirent* d;
+  if (! (d = real_readdir (dirp)))
     {
       fprintf (stderr, "Failed to get dirent\n");
       errno = ENOENT;
@@ -90,8 +90,10 @@ for READDIR_PARTIAL in '' '1'; do
   rm -f preloaded
   (export LD_PRELOAD=$LD_PRELOAD:./k.so
    returns_ 1 rm -Rf dir 2>>err) || fail=1
-  test -f preloaded ||
+  if ! test -f preloaded; then
+    cat err
     skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
+  fi
 done
 
 # First case is failure to read any items from dir, then assume empty.
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]