summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2019-09-02 10:28:42 +1000
committerDamien Miller <djm@mindrot.org>2019-09-02 10:28:42 +1000
commit368f1cc2fbd6ad10c66bc1b67c2c04aebf8a04a8 (patch)
tree18f90059cb08e61483eed6db730373dc344b6118 /openbsd-compat
parent6b7c53498def19a14dd9587bf521ab6dbee8988f (diff)
fixed test in OSX closefrom() replacement
from likan_999.student AT sina.com
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-closefrom.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-closefrom.c b/openbsd-compat/bsd-closefrom.c
index 8b9a5627..8fadca2d 100644
--- a/openbsd-compat/bsd-closefrom.c
+++ b/openbsd-compat/bsd-closefrom.c
@@ -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);
}