]> git.armaanb.net Git - opendoas.git/commitdiff
libopenbsd/closefrom: correctly handle snprintf truncation
authorDuncaen <mail@duncano.de>
Wed, 30 Jan 2019 20:06:15 +0000 (21:06 +0100)
committerDuncaen <mail@duncano.de>
Wed, 30 Jan 2019 20:06:15 +0000 (21:06 +0100)
libopenbsd/closefrom.c

index 9380b33a7247f14e975a5ea2daee8f357094f5a4..b56476a2d85895d1d378ffeeba09da892552ce3f 100644 (file)
@@ -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' &&