* server.c (handle_query) <qSupported>: Do two passes over the

qSupported string to avoid nesting strtok.
This commit is contained in:
Pedro Alves 2010-06-01 12:47:33 +00:00
parent 46d00b8af1
commit d149dd1dab
2 changed files with 39 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* server.c (handle_query) <qSupported>: Do two passes over the
qSupported string to avoid nesting strtok.
2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* Makefile.in (SFILES): Add $(srcdir)/proc-service.list.

View File

@ -1346,10 +1346,25 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
feature will follow a ':', and latter features will follow
';'. */
if (*p == ':')
{
char **qsupported = NULL;
int count = 0;
int i;
/* Two passes, to avoid nested strtok calls in
target_process_qsupported. */
for (p = strtok (p + 1, ";");
p != NULL;
p = strtok (NULL, ";"))
{
count++;
qsupported = xrealloc (qsupported, count * sizeof (char *));
qsupported[count - 1] = xstrdup (p);
}
for (i = 0; i < count; i++)
{
p = qsupported[i];
if (strcmp (p, "multiprocess+") == 0)
{
/* GDB supports and wants multi-process support if
@ -1359,6 +1374,11 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
}
else
target_process_qsupported (p);
free (p);
}
free (qsupported);
}
sprintf (own_buf, "PacketSize=%x;QPassSignals+", PBUFSIZ - 1);