[PATCH] Fix overflow in jobs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix overflow in jobs

Natanael Copa
This fixes an issue with bash hanging if user process rlimit is too
high.

To reproduce:

  ulimit -u 9223372036854775807
  bash -c 'sleep 1 & wait $!'
---
 jobs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jobs.c b/jobs.c
index fc966036..d203db27 100644
--- a/jobs.c
+++ b/jobs.c
@@ -765,7 +765,7 @@ bgp_resize ()
   else
     nsize = bgpids.nalloc;
 
-  while (nsize < js.c_childmax)
+  while (nsize < (ps_index_t)js.c_childmax)
     nsize *= 2;
 
   if (bgpids.nalloc < js.c_childmax)
--
2.15.0


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix overflow in jobs

Chet Ramey
On 12/7/17 5:36 PM, Natanael Copa wrote:
> This fixes an issue with bash hanging if user process rlimit is too
> high.

Thanks for the report.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://tiswww.cwru.edu/~chet/