On Wed, 22 Jun 2016, Bernhard Voelker wrote:

On 06/22/2016 02:48 PM, Pádraig Brady wrote:
On 22/06/16 13:18, Bernhard Voelker wrote:
Unfortunately, it seems we don't have test for fts.c, do we?

Not that I know of.
For effective testing of this you'd have to use something like cmocka,
or more generically something like CharybdeFS

For rm(1), we could add a gdb-based or LD_PRELOAD-based test.  Current rm(1)
will fail to remove a recursive directory (because some files beneath the
directory hierarchy didn't get deleted)

It was a recursive rm that made me start looking at this condition. Attached, please find the LD_PRELOAD that I used to simulate my buggy NFS server.

Obviously, many other packages usig FTS like find(1) are also affected.

On the plus side, the fts programs are much easier to fix.

My investigations show that readdir error checks in general are are rarely done, and if they are done, they are often done incorrectly. One program went into an infinite loop if readdir failed (it assumed that readdir would always make some progress each time) and another claimed that readdir doesn't report errors, which I doubt is true on any platform.

Peter
/* gcc -fPIC -shared -o libfake_readdir.so fake_readdir.c */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>

struct dirent *readdir(DIR *dirp)
{
	fprintf(stderr, "Forcing failure of readdir\n");
	errno=ELOOP;
	return NULL;
}

struct dirent64 *readdir64(DIR *dirp)
{
	fprintf(stderr, "Forcing failure of readdir64\n");
	errno=ELOOP;
	return NULL;
}

Reply via email to