From: Duncaen Date: Wed, 30 Jan 2019 20:06:15 +0000 (+0100) Subject: libopenbsd/closefrom: correctly handle snprintf truncation X-Git-Tag: v6.6~38 X-Git-Url: https://git.armaanb.net/?p=opendoas.git;a=commitdiff_plain;h=365f92247952a8be6d8e40b6770589dbe169825c libopenbsd/closefrom: correctly handle snprintf truncation --- 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' &&