mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] fix sysconf for inifinite rlimits
@ 2017-12-07 22:18 Natanael Copa
  2017-12-15  2:28 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Natanael Copa @ 2017-12-07 22:18 UTC (permalink / raw)
  To: musl; +Cc: Natanael Copa

sysconf should return -1 for infinity, not LONG_MAX.
---
 src/conf/sysconf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
index b8b761d0..9ce330a5 100644
--- a/src/conf/sysconf.c
+++ b/src/conf/sysconf.c
@@ -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;
 	}
 
-- 
2.15.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix sysconf for inifinite rlimits
  2017-12-07 22:18 [PATCH] fix sysconf for inifinite rlimits Natanael Copa
@ 2017-12-15  2:28 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2017-12-15  2:28 UTC (permalink / raw)
  To: musl

On Thu, Dec 07, 2017 at 11:18:54PM +0100, Natanael Copa wrote:
> sysconf should return -1 for infinity, not LONG_MAX.
> ---
>  src/conf/sysconf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
> index b8b761d0..9ce330a5 100644
> --- a/src/conf/sysconf.c
> +++ b/src/conf/sysconf.c
> @@ -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;
>  	}
>  
> -- 
> 2.15.0

Thanks. Committing with typo fix. ;-)

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-15  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-07 22:18 [PATCH] fix sysconf for inifinite rlimits Natanael Copa
2017-12-15  2:28 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).