* [patch 1/3] Code cleanup: strcpy + strlen -> sprintf
@ 2011-10-18 20:52 Jan Kratochvil
2011-10-19 0:24 ` Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2011-10-18 20:52 UTC (permalink / raw)
To: gdb-patches; +Cc: Paul Pluzhnikov
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");
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [patch 1/3] Code cleanup: strcpy + strlen -> sprintf 2011-10-18 20:52 [patch 1/3] Code cleanup: strcpy + strlen -> sprintf Jan Kratochvil @ 2011-10-19 0:24 ` Mark Kettenis 2011-10-19 8:40 ` Jan Kratochvil 0 siblings, 1 reply; 5+ messages in thread From: Mark Kettenis @ 2011-10-19 0:24 UTC (permalink / raw) To: jan.kratochvil; +Cc: gdb-patches, ppluzhnikov > > 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. Please use snprintf(3) instead of sprintf(3). ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/3] Code cleanup: strcpy + strlen -> sprintf 2011-10-19 0:24 ` Mark Kettenis @ 2011-10-19 8:40 ` Jan Kratochvil 2011-10-19 14:08 ` Tom Tromey 0 siblings, 1 reply; 5+ messages in thread From: Jan Kratochvil @ 2011-10-19 8:40 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches, ppluzhnikov On Wed, 19 Oct 2011 00:09:50 +0200, Mark Kettenis wrote: > > I hope it is not due to incompatible sprintf on > > MS-Windows CE or some such gdbserver platform. > > Please use snprintf(3) instead of sprintf(3). I am unfamiliar with gdbserver but there is no single use of snprintf while 75 uses of sprintf. Isn't it for some platform compatibility? Thanks, Jan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/3] Code cleanup: strcpy + strlen -> sprintf 2011-10-19 8:40 ` Jan Kratochvil @ 2011-10-19 14:08 ` Tom Tromey 2011-10-19 14:40 ` Jan Kratochvil 0 siblings, 1 reply; 5+ messages in thread From: Tom Tromey @ 2011-10-19 14:08 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Mark Kettenis, gdb-patches, ppluzhnikov Jan> I am unfamiliar with gdbserver but there is no single use of snprintf while Jan> 75 uses of sprintf. Isn't it for some platform compatibility? The gnulib page is informative: http://www.gnu.org/s/hello/manual/gnulib/snprintf.html Tom ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/3] Code cleanup: strcpy + strlen -> sprintf 2011-10-19 14:08 ` Tom Tromey @ 2011-10-19 14:40 ` Jan Kratochvil 0 siblings, 0 replies; 5+ messages in thread From: Jan Kratochvil @ 2011-10-19 14:40 UTC (permalink / raw) To: Tom Tromey; +Cc: Mark Kettenis, gdb-patches, ppluzhnikov On Wed, 19 Oct 2011 15:57:44 +0200, Tom Tromey wrote: > Jan> I am unfamiliar with gdbserver but there is no single use of snprintf while > Jan> 75 uses of sprintf. Isn't it for some platform compatibility? > > The gnulib page is informative: > > http://www.gnu.org/s/hello/manual/gnulib/snprintf.html thanks, this and http://www.gnu.org/s/hello/manual/gnulib/sprintf.html would suggest sprintf wrt OS compatibility is OK but snprintf is not and therefore this [patch 1/3] is the best + compatible variant. Still I no longer mind much, I am going to drop this 3-part series (unless discussed otherwise) and return back to the former form with incompatible/new SVR4 protocol and separate protocol producer/consumer: Re: [patch 3/3] Implement qXfer:libraries for Linux/gdbserver #2 http://sourceware.org/ml/gdb-patches/2011-10/msg00175.html This variant has no technical advantages, the code is just more tricky. Thanks, Jan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-19 14:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-10-18 20:52 [patch 1/3] Code cleanup: strcpy + strlen -> sprintf Jan Kratochvil 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox