]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
fixed test in OSX closefrom() replacement
authorDamien Miller <djm@mindrot.org>
Mon, 2 Sep 2019 00:28:42 +0000 (10:28 +1000)
committerDamien Miller <djm@mindrot.org>
Mon, 2 Sep 2019 00:28:42 +0000 (10:28 +1000)
from likan_999.student AT sina.com

openbsd-compat/bsd-closefrom.c

index 8b9a5627878ef4645026eb1e6c7fef38a73e62a9..8fadca2dad6625931b6acb9384a8082a634424bd 100644 (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);
        }