Commit e65b106a authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Xtrans: update to Xorg/xtrans upstream (1.3.5+)

This lifts xtrans to the state of this commit: commit 560d7550e23e9b14056b4a9b2569c2f256015f8a Author: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Date: Sat Sep 10 22:09:51 2016 -0700 Update strlcpy macro check to also check HAVE_STRLCPY xorg-server moved from HAS_STRLCPY to HAVE_STRLCPY in 2011 cf-xserver: d829a7c5cb42c979b58f3547136df5b05d906423 Signed-off-by: 's avatarJeremy Huddleston Sequoia <jeremyhu@apple.com>
parent 793d587b
......@@ -52,117 +52,75 @@ from The Open Group.
#include <nx-X11/Xfuncproto.h>
#include <nx-X11/Xos.h>
#include <nx-X11/Xmd.h>
#ifndef WIN32
#include <sys/socket.h>
#endif
#ifdef __clang__
/* Not all clients make use of all provided statics */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
/*
* Set the functions names according to where this code is being compiled.
*/
#ifdef X11_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _X11Trans##func
#else
#define TRANS(func) _X11Trans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_X11Trans";
static const char *__xtransname = "_X11Trans";
#endif
#endif /* X11_t */
#ifdef XSERV_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _XSERVTrans##func
#else
#define TRANS(func) _XSERVTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_XSERVTrans";
static const char *__xtransname = "_XSERVTrans";
#endif
#define X11_t
#endif /* XSERV_t */
#ifdef XIM_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _XimXTrans##func
#else
#define TRANS(func) _XimXTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_XimTrans";
static const char *__xtransname = "_XimTrans";
#endif
#endif /* XIM_t */
#ifdef FS_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _FSTrans##func
#else
#define TRANS(func) _FSTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_FSTrans";
static const char *__xtransname = "_FSTrans";
#endif
#endif /* FS_t */
#ifdef FONT_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _FontTrans##func
#else
#define TRANS(func) _FontTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_FontTrans";
static const char *__xtransname = "_FontTrans";
#endif
#endif /* FONT_t */
#ifdef ICE_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _IceTrans##func
#else
#define TRANS(func) _IceTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_IceTrans";
static const char *__xtransname = "_IceTrans";
#endif
#endif /* ICE_t */
#ifdef TEST_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _TESTTrans##func
#else
#define TRANS(func) _TESTTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_TESTTrans";
#endif
#endif /* TEST_t */
#ifdef LBXPROXY_t
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _LBXPROXYTrans##func
#else
#define TRANS(func) _LBXPROXYTrans/**/func
#endif
#define X11_t /* The server defines this - so should the LBX proxy */
#ifdef XTRANSDEBUG
static char* __xtransname = "_LBXPROXYTrans";
#endif
#endif /* LBXPROXY_t */
#if !defined(TRANS)
#if !defined(UNIXCPP) || defined(ANSICPP)
#define TRANS(func) _XTrans##func
#else
#define TRANS(func) _XTrans/**/func
#endif
#ifdef XTRANSDEBUG
static char* __xtransname = "_XTrans";
static const char *__xtransname = "_XTrans";
#endif
#endif /* !TRANS */
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/*
* Create a single address structure that can be used wherever
......@@ -190,7 +148,7 @@ typedef long BytesReadable_t;
#endif
#if defined(WIN32) || (defined(USG) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__))
#if defined(WIN32) || defined(USG)
/*
* TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
......@@ -264,7 +222,7 @@ void TRANS(FreeConnInfo) (
#ifdef TRANS_CLIENT
XtransConnInfo TRANS(OpenCOTSClient)(
char * /* address */
const char * /* address */
);
#endif /* TRANS_CLIENT */
......@@ -272,7 +230,7 @@ XtransConnInfo TRANS(OpenCOTSClient)(
#ifdef TRANS_SERVER
XtransConnInfo TRANS(OpenCOTSServer)(
char * /* address */
const char * /* address */
);
#endif /* TRANS_SERVER */
......@@ -282,7 +240,7 @@ XtransConnInfo TRANS(OpenCOTSServer)(
XtransConnInfo TRANS(ReopenCOTSServer)(
int, /* trans_id */
int, /* fd */
char * /* port */
const char * /* port */
);
int TRANS(GetReopenInfo)(
......@@ -305,12 +263,24 @@ int TRANS(SetOption)(
int TRANS(CreateListener)(
XtransConnInfo, /* ciptr */
char *, /* port */
const char *, /* port */
unsigned int /* flags */
);
int TRANS(Received) (
const char* /* protocol*/
);
int TRANS(NoListen) (
char* /* protocol*/
const char* /* protocol*/
);
int TRANS(Listen) (
const char* /* protocol*/
);
int TRANS(IsListening) (
const char* /* protocol*/
);
int TRANS(ResetListener)(
......@@ -328,7 +298,7 @@ XtransConnInfo TRANS(Accept)(
int TRANS(Connect)(
XtransConnInfo, /* ciptr */
char * /* address */
const char * /* address */
);
#endif /* TRANS_CLIENT */
......@@ -362,6 +332,10 @@ int TRANS(Writev)(
int /* size */
);
int TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close);
int TRANS(RecvFd) (XtransConnInfo ciptr);
int TRANS(Disconnect)(
XtransConnInfo /* ciptr */
);
......@@ -378,12 +352,15 @@ int TRANS(IsLocal)(
XtransConnInfo /* ciptr */
);
#ifdef NX_TRANS_SOCKET
/* needed for pre-xcb libX11 as we have in NX */
int TRANS(GetMyAddr)(
XtransConnInfo, /* ciptr */
int *, /* familyp */
int *, /* addrlenp */
Xtransaddr ** /* addrp */
XtransConnInfo, /* ciptr */
int *, /* familyp */
int *, /* addrlenp */
Xtransaddr ** /* addrp */
);
#endif
int TRANS(GetPeerAddr)(
XtransConnInfo, /* ciptr */
......@@ -399,7 +376,7 @@ int TRANS(GetConnectionNumber)(
#ifdef TRANS_SERVER
int TRANS(MakeAllCOTSServerListeners)(
char *, /* port */
const char *, /* port */
int *, /* partial */
int *, /* count_ret */
XtransConnInfo ** /* ciptrs_ret */
......
......@@ -68,7 +68,7 @@ from The Open Group.
* message.
*/
#ifndef XTRANSDEBUG
#if !defined(XTRANSDEBUG) && defined(XTRANS_TRANSPORT_C)
# define XTRANSDEBUG 1
#endif
......@@ -78,6 +78,10 @@ from The Open Group.
#include "Xtrans.h"
#ifndef _X_UNUSED /* Defined in Xfuncproto.h in xproto >= 7.0.22 */
# define _X_UNUSED /* */
#endif
#ifdef XTRANSDEBUG
# include <stdio.h>
#endif /* XTRANSDEBUG */
......@@ -94,7 +98,7 @@ from The Open Group.
* to avoid a race condition. JKJ (6/5/97)
*/
# if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SCO__)
# if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)
# ifndef NEED_UTSNAME
# define NEED_UTSNAME
# endif
......@@ -119,6 +123,16 @@ from The Open Group.
#define X_TCP_PORT 6000
#endif
#if XTRANS_SEND_FDS
struct _XtransConnFd {
struct _XtransConnFd *next;
int fd;
int do_close;
};
#endif
struct _XtransConnInfo {
struct _Xtransport *transptr;
int index;
......@@ -131,33 +145,35 @@ struct _XtransConnInfo {
int addrlen;
char *peeraddr;
int peeraddrlen;
struct _XtransConnFd *recv_fds;
struct _XtransConnFd *send_fds;
};
#define XTRANS_OPEN_COTS_CLIENT 1
#define XTRANS_OPEN_COTS_SERVER 2
typedef struct _Xtransport {
char *TransName;
const char *TransName;
int flags;
#ifdef TRANS_CLIENT
XtransConnInfo (*OpenCOTSClient)(
struct _Xtransport *, /* transport */
char *, /* protocol */
char *, /* host */
char * /* port */
const char *, /* protocol */
const char *, /* host */
const char * /* port */
);
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
char ** nolisten;
const char ** nolisten;
XtransConnInfo (*OpenCOTSServer)(
struct _Xtransport *, /* transport */
char *, /* protocol */
char *, /* host */
char * /* port */
const char *, /* protocol */
const char *, /* host */
const char * /* port */
);
#endif /* TRANS_SERVER */
......@@ -167,7 +183,7 @@ typedef struct _Xtransport {
XtransConnInfo (*ReopenCOTSServer)(
struct _Xtransport *, /* transport */
int, /* fd */
char * /* port */
const char * /* port */
);
#endif /* TRANS_REOPEN */
......@@ -185,7 +201,7 @@ typedef struct _Xtransport {
int (*CreateListener)(
XtransConnInfo, /* connection */
char *, /* port */
const char *, /* port */
unsigned int /* flags */
);
......@@ -204,8 +220,8 @@ typedef struct _Xtransport {
int (*Connect)(
XtransConnInfo, /* connection */
char *, /* host */
char * /* port */
const char *, /* host */
const char * /* port */
);
#endif /* TRANS_CLIENT */
......@@ -239,6 +255,18 @@ typedef struct _Xtransport {
int /* size */
);
#if XTRANS_SEND_FDS
int (*SendFd)(
XtransConnInfo, /* connection */
int, /* fd */
int /* do_close */
);
int (*RecvFd)(
XtransConnInfo /* connection */
);
#endif
int (*Disconnect)(
XtransConnInfo /* connection */
);
......@@ -268,8 +296,10 @@ typedef struct _Xtransport_table {
#define TRANS_LOCAL (1<<1) /* local transport */
#define TRANS_DISABLED (1<<2) /* Don't open this one */
#define TRANS_NOLISTEN (1<<3) /* Don't listen on this one */
#define TRANS_NOUNLINK (1<<4) /* Dont unlink transport endpoints */
#define TRANS_NOUNLINK (1<<4) /* Don't unlink transport endpoints */
#define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */
#define TRANS_NOXAUTH (1<<6) /* Don't verify authentication (because it's secure some other way at the OS layer) */
#define TRANS_RECEIVED (1<<7) /* The fd for this has already been opened by someone else. */
/* Flags to preserve when setting others */
#define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT)
......@@ -277,12 +307,18 @@ typedef struct _Xtransport_table {
#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when
building the transport.c file that has them in */
#ifdef __clang__
/* Not all clients make use of all provided statics */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
/*
* readv() and writev() don't exist or don't work correctly on some
* systems, so they may be emulated.
*/
#if (defined(SYSV) && defined(__i386__) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__)
#ifdef WIN32
#define READV(ciptr, iov, iovcnt) TRANS(ReadV)(ciptr, iov, iovcnt)
......@@ -296,10 +332,10 @@ static int TRANS(ReadV)(
#define READV(ciptr, iov, iovcnt) readv(ciptr->fd, iov, iovcnt)
#endif /* (SYSV && __i386__) || WIN32 || __sxg__ || */
#endif /* WIN32 */
#if (defined(SYSV) && defined(__i386__) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__)
#ifdef WIN32
#define WRITEV(ciptr, iov, iovcnt) TRANS(WriteV)(ciptr, iov, iovcnt)
......@@ -313,20 +349,24 @@ static int TRANS(WriteV)(
#define WRITEV(ciptr, iov, iovcnt) writev(ciptr->fd, iov, iovcnt)
#endif /* WIN32 || __sxg__ */
#endif /* WIN32 */
static int is_numeric (
char * /* str */
const char * /* str */
);
#ifdef TRANS_SERVER
static int trans_mkdir (
char *, /* path */
const char *, /* path */
int /* mode */
);
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/*
* Some XTRANSDEBUG stuff
*/
......
......@@ -55,7 +55,11 @@ from The Open Group.
*/
#ifdef XTHREADS
#include <nx-X11/Xthreads.h>
#include <X11/Xthreads.h>
#endif
#ifdef WIN32
#include <X11/Xlibint.h>
#include <X11/Xwinsock.h>
#endif
#ifdef X11_t
......@@ -193,11 +197,11 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
if (len > 0) {
if (*addrp && *addrlenp < (len + 1))
{
free ((char *) *addrp);
free (*addrp);
*addrp = NULL;
}
if (!*addrp)
*addrp = (Xtransaddr *) malloc (len + 1);
*addrp = malloc (len + 1);
if (*addrp) {
strcpy ((char *) *addrp, hostnamebuf);
*addrlenp = len;
......@@ -208,7 +212,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
else
{
if (*addrp)
free ((char *) *addrp);
free (*addrp);
*addrp = NULL;
*addrlenp = 0;
}
......@@ -221,6 +225,13 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
#ifdef ICE_t
/* Needed for _XGethostbyaddr usage in TRANS(GetPeerNetworkId) */
# if defined(TCPCONN) || defined(UNIXCONN)
# define X_INCLUDE_NETDB_H
# define XOS_USE_NO_LOCKING
# include <X11/Xos_r.h>
# endif
#include <signal.h>
char *
......@@ -231,7 +242,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
char *addr = ciptr->addr;
char hostnamebuf[256];
char *networkId = NULL;
char *transName = ciptr->transptr->TransName;
const char *transName = ciptr->transptr->TransName;
if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0)
{
......@@ -244,7 +255,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
case AF_UNIX:
{
struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
networkId = (char *) malloc (3 + strlen (transName) +
networkId = malloc (3 + strlen (transName) +
strlen (hostnamebuf) + strlen (saddr->sun_path));
sprintf (networkId, "%s/%s:%s", transName,
hostnamebuf, saddr->sun_path);
......@@ -273,8 +284,8 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
#endif
portnum = ntohs (saddr->sin_port);
sprintf (portnumbuf, "%d", portnum);
networkId = (char *) malloc (3 + strlen (transName) +
snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum);
networkId = malloc (3 + strlen (transName) +
strlen (hostnamebuf) + strlen (portnumbuf));
sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
break;
......@@ -295,24 +306,12 @@ static jmp_buf env;
#ifdef SIGALRM
static volatile int nameserver_timedout = 0;
static
#ifdef RETSIGTYPE /* set by autoconf AC_TYPE_SIGNAL */
RETSIGTYPE
#else /* Imake */
#ifdef SIGNALRETURNSINT
int
#else
void
#endif
#endif
nameserver_lost(int sig)
static void
nameserver_lost(int sig _X_UNUSED)
{
nameserver_timedout = 1;
longjmp (env, -1);
/* NOTREACHED */
#ifdef SIGNALRETURNSINT
return -1; /* for picky compilers */
#endif
}
#endif /* SIGALARM */
......@@ -407,8 +406,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
}
hostname = (char *) malloc (
strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
strcpy (hostname, ciptr->transptr->TransName);
strcat (hostname, "/");
if (addr)
......@@ -428,16 +426,16 @@ TRANS(WSAStartup) (void)
prmsg (2,"WSAStartup()\n");
if (!wsadata.wVersion && WSAStartup(0x0101, &wsadata))
if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
return 1;
return 0;
}
#endif
#include <ctype.h>
static int
is_numeric (char *str)
is_numeric (const char *str)
{
int i;
......@@ -468,7 +466,7 @@ is_numeric (char *str)
* bit cannot be set and fail.
*/
static int
trans_mkdir(char *path, int mode)
trans_mkdir(const char *path, int mode)
{
struct stat buf;
......@@ -480,7 +478,7 @@ trans_mkdir(char *path, int mode)
}
/* Dir doesn't exist. Try to create it */
#ifndef WIN32
#if !defined(WIN32) && !defined(__CYGWIN__)
/*
* 'sticky' bit requested: assume application makes
* certain security implications. If effective user ID
......@@ -575,6 +573,7 @@ trans_mkdir(char *path, int mode)
if (fstat(fd, &fbuf) == -1) {
prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n",
path, errno);
close(fd);
return -1;
}
/*
......@@ -586,6 +585,7 @@ trans_mkdir(char *path, int mode)
buf.st_ino != fbuf.st_ino) {
prmsg(1, "mkdir: ERROR: inode for %s changed\n",
path);
close(fd);
return -1;
}
if (updateOwner && fchown(fd, 0, 0) == 0)
......@@ -605,8 +605,10 @@ trans_mkdir(char *path, int mode)
return -1;
}
#endif
#if !defined(__APPLE_CC__) && !defined(__CYGWIN__)
prmsg(1, "mkdir: Owner of %s should be set to root\n",
path);
#endif
}
if (updateMode && !updatedMode) {
......
......@@ -47,18 +47,19 @@ from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef XSERV_t
#include "os.h"
#else
#include <stdlib.h>
#endif
#define XTRANS_TRANSPORT_C /* used to flag Xtransint.h that it's being used
here, not just #included in another file */
#include "Xtransint.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#ifdef LOCALCONN
#include "Xtranslcl.c"
#endif
......@@ -67,3 +68,7 @@ from The Open Group.
#endif
#include "Xtrans.c"
#include "Xtransutil.c"
#ifdef __clang__
#pragma clang diagnostic pop
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment