summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-closefrom.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2018-07-27 14:15:28 +1000
committerDamien Miller <djm@mindrot.org>2018-07-27 14:20:09 +1000
commit4492e2ec4e1956a277ef507f51d66e5c2aafaaf8 (patch)
tree90189a789dae6a8f7c9d39a17fc4131ccccc22ab /openbsd-compat/bsd-closefrom.c
parent149cab325a8599a003364ed833f878449c15f259 (diff)
correct snprintf truncation check in closefrom()
Truncation cannot happen unless the system has set PATH_MAX to some nonsensically low value. bz#2862, patch from Daniel Le
Diffstat (limited to 'openbsd-compat/bsd-closefrom.c')
-rw-r--r--openbsd-compat/bsd-closefrom.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/openbsd-compat/bsd-closefrom.c b/openbsd-compat/bsd-closefrom.c
index 9380b33a..b56476a2 100644
--- a/openbsd-compat/bsd-closefrom.c
+++ b/openbsd-compat/bsd-closefrom.c
@@ -77,7 +77,7 @@ closefrom(int lowfd)
/* Check for a /proc/$$/fd directory. */
len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid());
- if (len > 0 && (size_t)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) {
+ if (len > 0 && (size_t)len < sizeof(fdpath) && (dirp = opendir(fdpath))) {
while ((dent = readdir(dirp)) != NULL) {
fd = strtol(dent->d_name, &endp, 10);
if (dent->d_name != endp && *endp == '\0' &&