Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: gdb/gdbserver/hostio.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/gdbserver/hostio.h ('k') | gdb/gdbserver/hostio-errno.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/gdbserver/hostio.c
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index 72e334c414ce19ec5f042dda95575090d469c971..8edbadb45a2188a347c76b939dce70c47566a649 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -1,5 +1,5 @@
/* Host file transfer support for gdbserver.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2013 Free Software Foundation, Inc.
Contributed by CodeSourcery.
@@ -20,6 +20,7 @@
#include "server.h"
#include "gdb/fileio.h"
+#include "hostio.h"
#include <fcntl.h>
#include <limits.h>
@@ -50,6 +51,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 +73,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 +275,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 +451,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 +479,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;
@@ -483,7 +492,7 @@ handle_readlink (char *own_buf, int *new_packet_len)
return;
}
- ret = readlink (filename, linkname, sizeof linkname);
+ ret = readlink (filename, linkname, sizeof (linkname) - 1);
if (ret == -1)
{
hostio_error (own_buf);
« no previous file with comments | « gdb/gdbserver/hostio.h ('k') | gdb/gdbserver/hostio-errno.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698