fix sysconf for infinite rlimits
authorNatanael Copa <ncopa@alpinelinux.org>
Thu, 7 Dec 2017 22:18:54 +0000 (23:18 +0100)
committerRich Felker <dalias@aerifal.cx>
Fri, 15 Dec 2017 02:25:10 +0000 (21:25 -0500)
sysconf should return -1 for infinity, not LONG_MAX.

src/conf/sysconf.c

index b8b761d01a3156c644179dfe8aeb670d34b36a31..9ce330a5cfb172ef38720c826200bfc5fc4620c2 100644 (file)
@@ -174,6 +174,8 @@ long sysconf(int name)
        } else if (values[name] < -256) {
                struct rlimit lim;
                getrlimit(values[name]&16383, &lim);
+               if (lim.rlim_cur == RLIM_INFINITY)
+                       return -1;
                return lim.rlim_cur > LONG_MAX ? LONG_MAX : lim.rlim_cur;
        }