From: Jeremy Harris Date: Sat, 10 Oct 2020 14:04:53 +0000 (+0100) Subject: kevent: fix directory check X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/8c6732214b2c585148ead48b668a2cd819bde158 kevent: fix directory check --- 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)