diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f2bbd77558d..bb27f74de14 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-02-14 Thomas Schwinge + Pedro Alves + + * remote.c (remote_target::remote_parse_stop_reply): Avoid using + 'PATH_MAX'. + 2019-02-14 David Michael Samuel Thibault Thomas Schwinge diff --git a/gdb/remote.c b/gdb/remote.c index 18e678d07af..85af01e4b73 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7340,7 +7340,6 @@ Packet: '%s'\n"), else if (strprefix (p, p1, "exec")) { ULONGEST ignored; - char pathname[PATH_MAX]; int pathlen; /* Determine the length of the execd pathname. */ @@ -7349,11 +7348,14 @@ Packet: '%s'\n"), /* Save the pathname for event reporting and for the next run command. */ + char *pathname = (char *) xmalloc (pathlen + 1); + struct cleanup *old_chain = make_cleanup (xfree, pathname); hex2bin (p1, (gdb_byte *) pathname, pathlen); pathname[pathlen] = '\0'; + discard_cleanups (old_chain); /* This is freed during event handling. */ - event->ws.value.execd_pathname = xstrdup (pathname); + event->ws.value.execd_pathname = pathname; event->ws.kind = TARGET_WAITKIND_EXECD; /* Skip the registers included in this packet, since