This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] tracepoint remote.c:remote_trace_set_readonly_regions give up some regions if it is number is too big


Hi,

My GDB got crash with a ELF file when I use tracepoint with it.  I
found that it have 12898 sections.
So in remote_trace_set_readonly_regions:
      sprintf (target_buf + strlen (target_buf),
	       ":%s,%s", tmp1, tmp2);
It will over write other val, it make GDB crash.
So I add a check before it to fix it:
      if (strlen (target_buf) + strlen(tmp1) + strlen(tmp2) + 3 >
target_buf_size)
	{
	  warning (_("Give up some read only regions."));
	  break;
	}

Please help me review it.

And this issue affect 7.3 too. Does it can check in to 7.3?

Thanks,
Hui

2011-06-12  Hui Zhu  <teawater@gmail.com>

	* remote.c (remote_trace_set_readonly_regions): Add a check for
	target_buf_size.
---
 remote.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/remote.c
+++ b/remote.c
@@ -9996,6 +9996,11 @@ remote_trace_set_readonly_regions (void)
       size = bfd_get_section_size (s);
       sprintf_vma (tmp1, vma);
       sprintf_vma (tmp2, vma + size);
+      if (strlen (target_buf) + strlen(tmp1) + strlen(tmp2) + 3 >
target_buf_size)
+	{
+	  warning (_("Give up some read only regions."));
+	  break;
+	}
       sprintf (target_buf + strlen (target_buf),
 	       ":%s,%s", tmp1, tmp2);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]