[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#81033: queued bombs out with fatal error.



Package: queue
Version: 1.30.1-1

On running 'queue -i -- ls' from a terminal window, queued sends the
attached email.

The problem is the for loop at line 3226 of queued.c; an incorrect bound is
used in the for statement.

The enclosed patch cures the problem, by changing the loop bound from
RLIM_NLIMITS to the size of the appropriate array.

Ralph

--- Begin Message ---
QUEUED fatal error; queued terminating:
 - 7: invalid integer rlimit value

--- End Message ---
--- queue-1.30.1.orig/queued.c
+++ queue-1.30.1/queued.c
@@ -92,6 +92,44 @@
 
 #include "lex.h"
 
+#ifdef HAVE_GETRLIMIT
+/*
+ * Structure to match lex keywords to RLIMIT values and to small
+ * integers to index the q_rlimit array.
+ */
+static struct {
+  int r;
+  enum keyword kwd;
+} rtab[] = {
+#ifdef RLIMIT_CPU
+  RLIMIT_CPU,	K_RLIMITCPU,
+#endif
+#ifdef RLIMIT_FSIZE
+  RLIMIT_FSIZE,	K_RLIMITFSIZE,
+#endif
+#ifdef RLIMIT_DATA
+  RLIMIT_DATA,	K_RLIMITDATA,
+#endif
+#ifdef RLIMIT_STACK
+  RLIMIT_STACK,	K_RLIMITSTACK,
+#endif
+#ifdef RLIMIT_CORE
+  RLIMIT_CORE,	K_RLIMITCORE,
+#endif
+#ifdef RLIMIT_RSS
+  RLIMIT_RSS,	K_RLIMITRSS,
+#endif
+#ifdef RLIMIT_NOFILE
+  RLIMIT_NOFILE,  K_RLIMITNOFILE,
+#endif
+#ifdef RLIMIT_VMEM
+  RLIMIT_VMEM, K_RLIMITVMEM,
+#endif
+};
+
+#define NUM_RLIMITS (sizeof (rtab) / sizeof (rtab[0]))
+
+#endif
 
 /*
  * Generic queue_b structure.  The set of queues, jobs, and running
@@ -3223,7 +3261,7 @@
   /*Eric Deal <eric.deal@conexant.com> found that this setrlimit
 code breaks Solaris. Should test to see if it breaks other platforms
 as well. GNU/Linux seems OK.*/
-  for( i=0; i<RLIM_NLIMITS; i++ ){
+  for( i=0; i<NUM_RLIMITS; i++ ){
     register struct rlimit *rlp = &(qp->q_rlimit[i]);
     if( rlp->rlim_cur >= 0 && rlp->rlim_max >= 0 )
       (void) setrlimit( itorl(i), rlp );
@@ -3292,40 +3330,6 @@
 }
 
 #ifdef HAVE_GETRLIMIT
-/*
- * Structure to match lex keywords to RLIMIT values and to small
- * integers to index the q_rlimit array.
- */
-static struct {
-  int r;
-  enum keyword kwd;
-} rtab[] = {
-#ifdef RLIMIT_CPU
-  RLIMIT_CPU,	K_RLIMITCPU,
-#endif
-#ifdef RLIMIT_FSIZE
-  RLIMIT_FSIZE,	K_RLIMITFSIZE,
-#endif
-#ifdef RLIMIT_DATA
-  RLIMIT_DATA,	K_RLIMITDATA,
-#endif
-#ifdef RLIMIT_STACK
-  RLIMIT_STACK,	K_RLIMITSTACK,
-#endif
-#ifdef RLIMIT_CORE
-  RLIMIT_CORE,	K_RLIMITCORE,
-#endif
-#ifdef RLIMIT_RSS
-  RLIMIT_RSS,	K_RLIMITRSS,
-#endif
-#ifdef RLIMIT_NOFILE
-  RLIMIT_NOFILE,  K_RLIMITNOFILE,
-#endif
-#ifdef RLIMIT_VMEM
-  RLIMIT_VMEM, K_RLIMITVMEM,
-#endif
-};
-
 /* Turn RLIMIT manifest number into a small Integer 0 <= i < RLIM_NLIMITS
  * used to index the q_rlimit array.
  */
@@ -3334,7 +3338,7 @@
 {
   register int i;
 
-  for (i = 0; i < sizeof rtab/sizeof rtab[0]; i++)
+  for (i = 0; i < NUM_RLIMITS; i++)
     if (rtab[i].r == rl)
       return i;
   error1("%d: invalid RLIMIT value\n", rl);
@@ -3348,7 +3352,7 @@
 {
   register int i;
 
-  for (i = 0; i < sizeof rtab/sizeof rtab[0]; i++)
+  for (i = 0; i < NUM_RLIMITS; i++)
     if (rtab[i].kwd == kwd)
       return rtab[i].r;
   error1("%d: invalid keyword value\n", (int)kwd);
@@ -3360,7 +3364,7 @@
 int
 itorl(int i)
 {
-  if ((unsigned)i < sizeof rtab/sizeof rtab[0])
+  if ((unsigned)i < NUM_RLIMITS)
     return rtab[i].r;
   error1("%d: invalid integer rlimit value\n", i);
   /*NOTREACHED*/

Reply to: