diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2020-10-10 15:04:53 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2020-10-10 15:04:53 +0100 |
commit | 8c6732214b2c585148ead48b668a2cd819bde158 (patch) | |
tree | c12ad4d1083b1d503cce4d117cd2d257c13292fd | |
parent | ffbb6f2982821e44c42da6b8816e4560f5a9accb (diff) |
kevent: fix directory check
-rw-r--r-- | src/src/tls.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/src/tls.c b/src/src/tls.c index d213fefd6..5adab7c7b 100644 --- a/src/src/tls.c +++ b/src/src/tls.c @@ -165,15 +165,16 @@ if (Ustrcmp(filename, "system,cache") == 0) return TRUE; for (;;) { - if (!(s = Ustrrchr(filename, '/'))) return FALSE; - if ((lstat(CCS filename, &sb)) < 0) { s = US"lstat"; goto bad; } if (kev_used > KEV_SIZE-2) { s = US"out of kev space"; goto bad; } + if (!(s = Ustrrchr(filename, '/'))) return FALSE; + s = string_copyn(filename, s - filename); /* mem released by tls_set_watch */ /* The dir open will fail if there is a symlink on the path. Fine; it's too much effort to handle all possible cases; just refuse the preload. */ if ((fd2 = open(CCS s, O_RDONLY | O_NOFOLLOW)) < 0) { s = US"open dir"; goto bad; } + if ((lstat(CCS filename, &sb)) < 0) { s = US"lstat"; goto bad; } if (!S_ISLNK(sb.st_mode)) { if ((fd1 = open(CCS filename, O_RDONLY | O_NOFOLLOW)) < 0) |