pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/38988



The following reply was made to PR pkg/38988; it has been noted by GNATS.

From: Taylor R Campbell <campbell%mumble.net@localhost>
To: Taylor R Campbell <campbell%mumble.net@localhost>
Cc: gnats-bugs%netbsd.org@localhost, obache%netbsd.org@localhost
Subject: Re: pkg/38988
Date: Sun, 3 May 2009 13:36:50 -0400

 This is a multi-part message in MIME format.
 --=_hyuv25eOZgN+xAx9Jq99u51P1q/KtrRH
 
 This PR can now be closed, since x11/rxvt-unicode was updated to 9.06
 several weeks ago.  However, rxvt-unicode still has a problem with
 socket control message ancillary data alignment, for which I have
 submitted my patch upstream to the rxvt-unicode mailing list.  Until
 it is incorporated upstream, though, my patch (attached) may be worth
 adding as patch-ad to x11/rxvt-unicode.
 
 --=_hyuv25eOZgN+xAx9Jq99u51P1q/KtrRH
 Content-Type: text/plain; charset="ISO-8859-1"; name="fdpass"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="fdpass.patch"
 
 --- src/fdpass.C.orig  2007-06-25 23:47:14.000000000 +0000
 +++ src/fdpass.C       2008-08-09 00:41:29.000000000 +0000
 @@ -26,6 +26,7 @@
  #include "../config.h"
 =20
  #include <cstddef> // needed by broken bsds for NULL used in sys/uio.h
 +#include <cstdlib>
 =20
  #include <sys/types.h>
  #include <sys/uio.h>
 @@ -33,7 +34,12 @@
 =20
  #include "libptytty.h"
 =20
 -#ifndef CMSG_LEN // CMSG_SPACE && CMSG_LEN are rfc2292 extensions to unix
 +// CMSG_SPACE & CMSG_LEN are rfc2292 extensions to unix
 +#ifndef CMSG_SPACE
 +# define CMSG_SPACE(len) (sizeof (cmsghdr) + len)
 +#endif
 +
 +#ifndef CMSG_LEN
  # define CMSG_LEN(len) (sizeof (cmsghdr) + len)
  #endif
 =20
 @@ -42,9 +48,13 @@ ptytty::send_fd (int socket, int fd)
  {
    msghdr msg;
    iovec iov;
 -  char buf [CMSG_LEN (sizeof (int))];
 +  void *buf;
 +  cmsghdr *cmsg;
    char data =3D 0;
 =20
 +  if ((buf =3D malloc (CMSG_SPACE (sizeof (int)))) =3D=3D NULL)
 +    return 0;
 +
    iov.iov_base =3D &data;
    iov.iov_len  =3D 1;
 =20
 @@ -52,19 +62,19 @@ ptytty::send_fd (int socket, int fd)
    msg.msg_namelen    =3D 0;
    msg.msg_iov        =3D &iov;
    msg.msg_iovlen     =3D 1;
 -  msg.msg_control    =3D (void *)buf;
 -  msg.msg_controllen =3D sizeof buf;
 +  msg.msg_control    =3D buf;
 +  msg.msg_controllen =3D CMSG_SPACE (sizeof (int));
 =20
 -  cmsghdr *cmsg =3D CMSG_FIRSTHDR (&msg);
 +  cmsg =3D CMSG_FIRSTHDR (&msg);
    cmsg->cmsg_level =3D SOL_SOCKET;
    cmsg->cmsg_type  =3D SCM_RIGHTS;
    cmsg->cmsg_len   =3D CMSG_LEN (sizeof (int));
 =20
    *(int *)CMSG_DATA (cmsg) =3D fd;
 =20
 -  msg.msg_controllen =3D cmsg->cmsg_len;
 -
 -  return sendmsg (socket, &msg, 0) >=3D 0;
 +  ssize_t result =3D sendmsg (socket, &msg, 0);
 +  free (buf);
 +  return result >=3D 0;
  }
 =20
  int
 @@ -72,8 +82,13 @@ ptytty::recv_fd (int socket)
  {
    msghdr msg;
    iovec iov;
 -  char buf [CMSG_LEN (sizeof (int))];  /* ancillary data buffer */
 +  void *buf;
 +  cmsghdr *cmsg;
    char data =3D 1;
 +  int fd =3D -1;
 +
 +  if ((buf =3D malloc (CMSG_SPACE (sizeof (int)))) =3D=3D NULL)
 +    return -1;
 =20
    iov.iov_base =3D &data;
    iov.iov_len  =3D 1;
 @@ -83,23 +98,23 @@ ptytty::recv_fd (int socket)
    msg.msg_iov        =3D &iov;
    msg.msg_iovlen     =3D 1;
    msg.msg_control    =3D buf;
 -  msg.msg_controllen =3D sizeof buf;
 -
 -  cmsghdr *cmsg =3D CMSG_FIRSTHDR (&msg);
 -  cmsg->cmsg_level =3D SOL_SOCKET;
 -  cmsg->cmsg_type  =3D SCM_RIGHTS;
 -  cmsg->cmsg_len   =3D CMSG_LEN (sizeof (int));
 -
 -  msg.msg_controllen =3D cmsg->cmsg_len;
 +  msg.msg_controllen =3D CMSG_SPACE (sizeof (int));
 =20
    if (recvmsg (socket, &msg, 0) <=3D 0
        || data               !=3D 0
 -      || msg.msg_controllen < CMSG_LEN (sizeof (int))
 -      || cmsg->cmsg_level   !=3D SOL_SOCKET
 +      || msg.msg_controllen < CMSG_SPACE (sizeof (int)))
 +    goto exit;
 +
 +  cmsg =3D CMSG_FIRSTHDR (&msg);
 +  if (cmsg->cmsg_level      !=3D SOL_SOCKET
        || cmsg->cmsg_type    !=3D SCM_RIGHTS
        || cmsg->cmsg_len     < CMSG_LEN (sizeof (int)))
 -    return -1;
 +    goto exit;
 +
 +  fd =3D *(int *)CMSG_DATA (cmsg);
 =20
 -  return *(int *)CMSG_DATA (cmsg);
 + exit:
 +  free (buf);
 +  return fd;
  }
 
 --=_hyuv25eOZgN+xAx9Jq99u51P1q/KtrRH--
 


Home | Main Index | Thread Index | Old Index