From 365f92247952a8be6d8e40b6770589dbe169825c Mon Sep 17 00:00:00 2001 From: Duncaen Date: Wed, 30 Jan 2019 21:06:15 +0100 Subject: [PATCH] libopenbsd/closefrom: correctly handle snprintf truncation --- libopenbsd/closefrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libopenbsd/closefrom.c b/libopenbsd/closefrom.c index 9380b33..b56476a 100644 --- a/libopenbsd/closefrom.c +++ b/libopenbsd/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' && -- 2.39.2