From 2963ee1d7c76b0ce775d0037557cd82f8aae827c Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sun, 18 Jan 2004 03:37:03 +0000 Subject: [PATCH] * remote.c (remote_vcont_resume): Use xstrprintf instead of sprintf. --- gdb/ChangeLog | 4 ++++ gdb/remote.c | 33 +++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0404da023d1..52870f3609a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2004-01-17 Daniel Jacobowitz + + * remote.c (remote_vcont_resume): Use xstrprintf instead of sprintf. + 2004-01-17 Andrew Cagney * mdebugread.c: Update copyright. diff --git a/gdb/remote.c b/gdb/remote.c index 1ed3680c707..453074f8945 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2583,7 +2583,7 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal) { struct remote_state *rs = get_remote_state (); int pid = PIDGET (ptid); - char *buf = NULL; + char *buf = NULL, *outbuf; struct cleanup *old_cleanup; buf = xmalloc (rs->remote_packet_size); @@ -2608,40 +2608,45 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal) don't have any PID numbers the inferior will understand. Make sure to only send forms that do not specify a PID. */ if (step && siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;S%02x", siggnal); + outbuf = xstrprintf ("vCont;S%02x", siggnal); else if (step) - sprintf (buf, "vCont;s"); + outbuf = xstrprintf ("vCont;s"); else if (siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;C%02x", siggnal); + outbuf = xstrprintf ("vCont;C%02x", siggnal); else - sprintf (buf, "vCont;c"); + outbuf = xstrprintf ("vCont;c"); } else if (pid == -1) { /* Resume all threads, with preference for INFERIOR_PTID. */ if (step && siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;S%02x:%x;c", siggnal, PIDGET (inferior_ptid)); + outbuf = xstrprintf ("vCont;S%02x:%x;c", siggnal, + PIDGET (inferior_ptid)); else if (step) - sprintf (buf, "vCont;s:%x;c", PIDGET (inferior_ptid)); + outbuf = xstrprintf ("vCont;s:%x;c", PIDGET (inferior_ptid)); else if (siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;C%02x:%x;c", siggnal, PIDGET (inferior_ptid)); + outbuf = xstrprintf ("vCont;C%02x:%x;c", siggnal, + PIDGET (inferior_ptid)); else - sprintf (buf, "vCont;c"); + outbuf = xstrprintf ("vCont;c"); } else { /* Scheduler locking; resume only PTID. */ if (step && siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;S%02x:%x", siggnal, pid); + outbuf = xstrprintf ("vCont;S%02x:%x", siggnal, pid); else if (step) - sprintf (buf, "vCont;s:%x", pid); + outbuf = xstrprintf ("vCont;s:%x", pid); else if (siggnal != TARGET_SIGNAL_0) - sprintf (buf, "vCont;C%02x:%x", siggnal, pid); + outbuf = xstrprintf ("vCont;C%02x:%x", siggnal, pid); else - sprintf (buf, "vCont;c:%x", pid); + outbuf = xstrprintf ("vCont;c:%x", pid); } - putpkt (buf); + gdb_assert (outbuf && strlen (outbuf) < rs->remote_packet_size); + make_cleanup (xfree, outbuf); + + putpkt (outbuf); do_cleanups (old_cleanup); -- 2.30.2