Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@cygnus.com>
To: Petr Ledvina <ledvinap@kae.zcu.cz>
Cc: gdb-patches@sources.redhat.com
Subject: Re: bug in gdb/target.c:target_signal_to_name
Date: Sun, 13 Jan 2002 13:10:00 -0000	[thread overview]
Message-ID: <3C41F7AD.7040708@cygnus.com> (raw)
In-Reply-To: <Pine.OSF.4.33.0111301833160.4557-100000@eryx1.zcu.cz>

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

> When remote target returns some invalid signal, gdb vill crash with
> segfault. The problem seems to be in function target_signal_to_name,
> which doesn't check, if signal is in bounds and returns invalid name.
> 
> This version will (at least) not segfault:
> 
> /* Return the name for a signal.  */
> char *
> target_signal_to_name (sig)
>      enum target_signal sig;
> {
>   if (sig == TARGET_SIGNAL_UNKNOWN)
>     /* I think the code which prints this will always print it along with
>        the string, so no need to be verbose.  */
>     return "?";
>   if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
>     return signals[sig].name;
>   else
>     return signals[TARGET_SIGNAL_UNKNOWN].name;
> }


Thanks.  I've committed the attached.

	Andrew




[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1091 bytes --]

2002-01-13  Andrew Cagney  <ac131313@redhat.com>

	From Petr Ledvina <ledvinap@kae.zcu.cz>:
	* signals.c (target_signal_to_name): Verify that SIG is within the
	bounds of the signals array.

Index: signals.c
===================================================================
RCS file: /cvs/src/src/gdb/signals.c,v
retrieving revision 1.1
diff -p -r1.1 signals.c
*** signals.c	2001/07/19 18:09:11	1.1
--- signals.c	2002/01/13 21:04:30
*************** target_signal_to_name (enum target_signa
*** 214,220 ****
      /* I think the code which prints this will always print it along with
         the string, so no need to be verbose.  */
      return "?";
!   return signals[sig].name;
  }
  
  /* Given a name, return its signal.  */
--- 214,223 ----
      /* I think the code which prints this will always print it along with
         the string, so no need to be verbose.  */
      return "?";
!   else if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
!     return signals[sig].name;
!   else
!     return signals[sig].name;
  }
  
  /* Given a name, return its signal.  */

       reply	other threads:[~2002-01-13 21:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.OSF.4.33.0111301833160.4557-100000@eryx1.zcu.cz>
2002-01-13 13:10 ` Andrew Cagney [this message]
2002-01-13 13:13   ` Daniel Jacobowitz
2002-01-13 13:55     ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C41F7AD.7040708@cygnus.com \
    --to=ac131313@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=ledvinap@kae.zcu.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox