+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".
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)
{
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)
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;
static void
handle_unlink (char *own_buf)
{
- char filename[PATH_MAX];
+ char filename[HOSTIO_PATH_MAX];
char *p;
int ret;
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;