List Info

Thread: Coverity: Patch/Fix CID 17 OVERRUN_STATIC File: ruby/signal.c




Coverity: Patch/Fix CID 17 OVERRUN_STATIC File: ruby/signal.c
user name
2006-05-05 04:38:47
Hello Kevin,

>static struct {
>VALUE cmd;
>int safe;
>} trap_list[NSIG];
>
>633         if (sig < 0 || sig > NSIG) {
>634             rb_raise(rb_eArgError, "invalid
signal number (%d)", sig);
>635         }
>
>trap_list is only NSIG big so the "if"
should be >=NSIG
>Arrays are zero based in C.

   I agree that this is a valid bug. When I checked this, I
couldn't find
whether ruby
  map given signal number to correct C array number e.g
signal 1 -> becomes
0 and
  so on.  If ruby does not do this it is a bug, because then
we lost the
last signal (the signal
 with the biggest number). So we probably should do sig =
sig - 1 in the
begin of the function?



>
>
>Index: signal.c
>========================================================
===========
>RCS file: /src/ruby/signal.c,v
>retrieving revision 1.72
>diff -u -r1.72 signal.c
>--- signal.c    9 Jan 2006 22:32:55 -0000       1.72
>+++ signal.c    5 May 2006 02:24:42 -0000
> -630,7 +630,7 
>rb_raise(rb_eArgError, "unsupported signal
SIG%s", s);
>}
>
>-    if (sig < 0 || sig > NSIG) {
>+    if (sig < 0 || sig >= NSIG) {
>rb_raise(rb_eArgError, "invalid signal number
(%d)", sig);
>}
>#if defined(HAVE_SETITIMER)
>
>



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )