fixed test in OSX closefrom() replacement

from likan_999.student AT sina.com
This commit is contained in:
Damien Miller 2019-09-02 10:28:42 +10:00
parent 6b7c53498d
commit 368f1cc2fb

View File

@ -107,9 +107,9 @@ closefrom(int lowfd)
if ((fdinfo_buf = malloc(sz)) == NULL)
goto fallback;
r = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fdinfo_buf, sz);
if (r < 0 || r >= sz)
if (r < 0 || r > sz)
goto fallback;
for (i = 0; i < sz / (int)PROC_PIDLISTFD_SIZE; i++) {
for (i = 0; i < r / (int)PROC_PIDLISTFD_SIZE; i++) {
if (fdinfo_buf[i].proc_fd >= lowfd)
close(fdinfo_buf[i].proc_fd);
}