summaryrefslogtreecommitdiff
path: root/src/misc/nftw.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-18 21:17:03 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-18 21:17:03 -0400
commitdf9e11bb063446df760e8f7c62ea5eb6ba3faa34 (patch)
treef8101b43b95f974c6a510a71a167b96563cfb7d6 /src/misc/nftw.c
parentd2c604d5a40bc75fe83a62fd20377c20a73aa0d5 (diff)
downloadmusl-df9e11bb063446df760e8f7c62ea5eb6ba3faa34.tar.gz
protect ftw and nftw against cancellation
Diffstat (limited to 'src/misc/nftw.c')
-rw-r--r--src/misc/nftw.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/misc/nftw.c b/src/misc/nftw.c
index 1b94ac15..63d6aff5 100644
--- a/src/misc/nftw.c
+++ b/src/misc/nftw.c
@@ -7,6 +7,7 @@
#include <unistd.h>
#include <string.h>
#include <limits.h>
+#include <pthread.h>
#include "libc.h"
struct history
@@ -103,6 +104,7 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int fd_limit, int flags)
{
+ int r, cs;
size_t l;
char pathbuf[PATH_MAX+1];
@@ -115,7 +117,10 @@ int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, str
}
memcpy(pathbuf, path, l+1);
- return do_nftw(pathbuf, fn, fd_limit, flags, NULL);
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+ r = do_nftw(pathbuf, fn, fd_limit, flags, NULL);
+ pthread_setcancelstate(cs, 0);
+ return r;
}
LFS64(nftw);