summaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-07-01 11:29:17 +0000
committerPedro Alves <palves@redhat.com>2013-07-01 11:29:17 +0000
commit9d3e98c844fe7c4e5e45a5552847d864eb0c1946 (patch)
tree2871e5a0ce478e902f352a846538fd7ead2fa98b /gdb/gdbserver
parent212fe135e533bb0e9667e42d7e3cbba5a12e1c7c (diff)
downloadgdb-9d3e98c844fe7c4e5e45a5552847d864eb0c1946.tar.gz
[GDBserver] hostio.c: Fallback to packet buffer size if PATH_MAX is not available.
PATH_MAX is not defined on systems which have no limit on filename length, such as GNU/Hurd. As designed, the hostio RSP packets carry the paths as parameters in the request/reply packets, which themselves have an upper size limit, so lifting the filename limit completely would require a redesign with new hostio packets. While that doesn't happen, we can at least support filename lengths as long as the packet buffer can fit. gdb/gdbserver/ 2013-07-01 Pedro Alves <palves@redhat.com> * hostio.c (HOSTIO_PATH_MAX): Define. (require_filename, handle_open, handle_unlink, handle_readlink): Use it.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog6
-rw-r--r--gdb/gdbserver/hostio.c16
2 files changed, 18 insertions, 4 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 4e7fe005859..91a3f9ba75c 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2013-07-01 Pedro Alves <palves@redhat.com>
+ * hostio.c (HOSTIO_PATH_MAX): Define.
+ (require_filename, handle_open, handle_unlink, handle_readlink):
+ Use it.
+
+2013-07-01 Pedro Alves <palves@redhat.com>
+
* server.h: Include "pathmax.h".
* linux-low.c: Don't include sys/param.h.
(linux_pid_exe_is_elf_64_file): Use PATH_MAX instead of
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index df94d31ca70..a74c2f880df 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -50,6 +50,14 @@ safe_fromhex (char a, int *nibble)
return 0;
}
+/* Filenames are hex encoded, so the maximum we can handle is half the
+ packet buffer size. Cap to PATH_MAX, if it is shorter. */
+#if !defined (PATH_MAX) || (PATH_MAX > (PBUFSIZ / 2 + 1))
+# define HOSTIO_PATH_MAX (PBUFSIZ / 2 + 1)
+#else
+# define HOSTIO_PATH_MAX PATH_MAX
+#endif
+
static int
require_filename (char **pp, char *filename)
{
@@ -64,7 +72,7 @@ require_filename (char **pp, char *filename)
int nib1, nib2;
/* Don't allow overflow. */
- if (count >= PATH_MAX - 1)
+ if (count >= HOSTIO_PATH_MAX - 1)
return -1;
if (safe_fromhex (p[0], &nib1)
@@ -266,7 +274,7 @@ fileio_open_flags_to_host (int fileio_open_flags, int *open_flags_p)
static void
handle_open (char *own_buf)
{
- char filename[PATH_MAX];
+ char filename[HOSTIO_PATH_MAX];
char *p;
int fileio_flags, mode, flags, fd;
struct fd_list *new_fd;
@@ -442,7 +450,7 @@ handle_close (char *own_buf)
static void
handle_unlink (char *own_buf)
{
- char filename[PATH_MAX];
+ char filename[HOSTIO_PATH_MAX];
char *p;
int ret;
@@ -470,7 +478,7 @@ static void
handle_readlink (char *own_buf, int *new_packet_len)
{
#if defined (HAVE_READLINK)
- char filename[PATH_MAX], linkname[PATH_MAX];
+ char filename[HOSTIO_PATH_MAX], linkname[HOSTIO_PATH_MAX];
char *p;
int ret, bytes_sent;