From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Paul Pluzhnikov <ppluzhnikov@google.com>
Subject: [patch 1/3] Code cleanup: strcpy + strlen -> sprintf
Date: Tue, 18 Oct 2011 20:52:00 -0000 [thread overview]
Message-ID: <20111018205108.GA31533@host1.jankratochvil.net> (raw)
Hi,
I do not understand much the reasons, maybe a fear about violating C sequence
points. I hope it is not due to incompatible sprintf on MS-Windows CE or some
such gdbserver platform.
I would check it in with the other patches depending on this.
Thanks,
Jan
gdb/gdbserver/
2011-10-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* server.c (handle_qxfer_libraries): Replace strcpy and strlen pairs by
sprintf.
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -960,18 +960,11 @@ handle_qxfer_libraries (const char *annex,
struct dll_info *dll = (struct dll_info *) dll_ptr;
char *name;
- strcpy (p, " <library name=\"");
- p = p + strlen (p);
name = xml_escape_text (dll->name);
- strcpy (p, name);
+ p += sprintf (p, " <library name=\"%s\"><segment address=\"0x%lx\"/>"
+ "</library>\n",
+ name, (long) dll->base_addr);
free (name);
- p = p + strlen (p);
- strcpy (p, "\"><segment address=\"");
- p = p + strlen (p);
- sprintf (p, "0x%lx", (long) dll->base_addr);
- p = p + strlen (p);
- strcpy (p, "\"/></library>\n");
- p = p + strlen (p);
}
strcpy (p, "</library-list>\n");
next reply other threads:[~2011-10-18 20:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 20:52 Jan Kratochvil [this message]
2011-10-19 0:24 ` Mark Kettenis
2011-10-19 8:40 ` Jan Kratochvil
2011-10-19 14:08 ` Tom Tromey
2011-10-19 14:40 ` Jan Kratochvil
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=20111018205108.GA31533@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=ppluzhnikov@google.com \
/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