xtrans: Changes to 'upstream-unstable'
.gitignore | 79 +++
COPYING | 39 -
Makefile.am | 14
README | 7
Xtrans.c | 294 ++++++-------
Xtrans.h | 70 ---
Xtransint.h | 139 +++---
Xtranslcl.c | 489 +++++++++++-----------
Xtranssock.c | 612 +++++++++++++---------------
Xtranstli.c | 637 ++++++++++++++---------------
Xtransutil.c | 106 ++--
configure.ac | 80 ++-
doc/.gitignore | 6
doc/Makefile.am | 13
doc/xtrans.xml | 1201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
docbook.am | 105 ++++
transport.c | 22 -
xtrans.m4 | 66 +--
18 files changed, 2646 insertions(+), 1333 deletions(-)
New commits:
commit 8ce5ecd33b05becc054dbd07f87e385165b6c979
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Mar 22 20:04:07 2012 -0700
xtrans 1.2.7
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/configure.ac b/configure.ac
index 5f1743c..3d11c34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([xtrans], [1.2.6],
+AC_INIT([xtrans], [1.2.7],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans])
AC_CONFIG_SRCDIR([Makefile.am])
commit f8eea0bf256de59602790b6a7c7877b31520440f
Author: Matt Dew <marcoz@osource.org>
Date: Wed Jan 11 22:23:32 2012 -0700
informaltable cleanup
On certain tables, add top and bottom borders to table
header and a bottom border to the table. This matches
what those tables in the old pdfs looked like.
the <?dbfo keep-together='always'> prevents tables from
splitting across pages. Useful for tiny tables.
Converting the colwidth to a floating point,
IE, 1* -> 1.0* cleans up these build errors:
WARNING: table-layout="fixed" and column-width unspecified
=> falling back to proportional-column-width(1)
Signed-off-by: Matt Dew <marcoz@osource.org>
diff --git a/doc/xtrans.xml b/doc/xtrans.xml
index 82e95a4..12dbe3c 100644
--- a/doc/xtrans.xml
+++ b/doc/xtrans.xml
@@ -956,13 +956,14 @@ In X11R7 modular releases, these flags are set when running
<function>XTRANS_CONNECTION_FLAGS</function> macro from
<filename>xtrans.m4</filename>.
</para>
-<informaltable pgwide='0' frame='none'>
- <tgroup cols='3' align='left'>
- <colspec colname='define' align='center'/>
- <colspec colname='enable'/>
- <colspec colname='desc'/>
+
+<informaltable frame='topbot'>
+ <tgroup cols='3' align='left' colsep='0' rowsep='0'>
+ <colspec colname='define' colwidth='1.0*' />
+ <colspec colname='enable' colwidth='2.0*' />
+ <colspec colname='desc' colwidth='2.0*'/>
<thead>
- <row>
+ <row rowsep='1'>
<entry><code>#define</code></entry>
<entry>configure flag</entry>
<entry>Description</entry>
@@ -1021,15 +1022,15 @@ In X11R7 modular releases, these flags are set when running
<chapter id='Transport_Specific_Definitions'>
<title>Transport Specific Definitions</title>
-<informaltable pgwide='0' frame='none'>
+<informaltable frame='all' colsep='1' rowsep='1'>
<tgroup cols='4' align='center'>
- <colspec colname='c1'/>
- <colspec colname='c2'/>
- <colspec colname='c3'/>
- <colspec colname='c4'/>
+ <colspec colname='c1' colwidth='1.0*'/>
+ <colspec colname='c2' colwidth='1.0*'/>
+ <colspec colname='c3' colwidth='3.0*'/>
+ <colspec colname='c4' colwidth='2.0*'/>
<thead>
<row>
- <entry morerows="1" align='center'>Protocol Family</entry>
+ <entry morerows="1">Protocol Family</entry>
<entry namest="c2" nameend="c4" align='center'>Address Component</entry>
</row>
<row>
@@ -1040,34 +1041,34 @@ In X11R7 modular releases, these flags are set when running
</thead>
<tbody>
<row>
- <entry align='center'>Internet</entry>
- <entry align='center'>inet inet6 tcp udp</entry>
- <entry align='center'>name of an internet addressable host</entry>
- <entry align='center'>string containing the name of a service or a valid port number. Example: "xserver0", "7100"</entry>
+ <entry>Internet</entry>
+ <entry>inet inet6 tcp udp</entry>
+ <entry>name of an internet addressable host</entry>
+ <entry>string containing the name of a service or a valid port number. Example: "xserver0", "7100"</entry>
</row>
<row>
- <entry align='center'>DECnet</entry>
- <entry align='center'>decnet</entry>
- <entry align='center'>name of a DECnet addressable host</entry>
- <entry align='center'>string containing the complete name of the object. Example: "X$X0"</entry>
+ <entry>DECnet</entry>
+ <entry>decnet</entry>
+ <entry>name of a DECnet addressable host</entry>
+ <entry>string containing the complete name of the object. Example: "X$X0"</entry>
</row>
<row>
- <entry align='center'>NETware</entry>
- <entry align='center'>ipx</entry>
- <entry align='center'>name of a NETware addressable host</entry>
- <entry align='center'>Not sure of the specifics yet.</entry>
+ <entry>NETware</entry>
+ <entry>ipx</entry>
+ <entry>name of a NETware addressable host</entry>
+ <entry>Not sure of the specifics yet.</entry>
</row>
<row>
- <entry align='center'>OSI</entry>
- <entry align='center'>osi</entry>
- <entry align='center'>name of an OSI adressable host.</entry>
- <entry align='center'>Not sure of the specifics yet.</entry>
+ <entry>OSI</entry>
+ <entry>osi</entry>
+ <entry>name of an OSI adressable host.</entry>
+ <entry>Not sure of the specifics yet.</entry>
</row>
<row>
- <entry align='center'>Local</entry>
- <entry align='center'>local pts named sco isc</entry>
- <entry align='center'>(ignored)</entry>
- <entry align='center'>String containing the port name, ie "xserver0", "fontserver0".</entry>
+ <entry>Local</entry>
+ <entry>local pts named sco isc</entry>
+ <entry>(ignored)</entry>
+ <entry>String containing the port name, ie "xserver0", "fontserver0".</entry>
</row>
</tbody>
</tgroup>
commit 6086f6c1d0e0a1c9e590879acb2319dea0eb6e96
Author: Robert Bragg <robert@linux.intel.com>
Date: Mon Dec 12 00:30:43 2011 +0000
Xtranssock.c: avoid buffer overrun in SocketReopen
This function was constructing an address from a port string allocating
a buffer according to the size of the string but then later copying
the address according to sizeof(struct sockaddr).
This patch ensures that we allocate a struct sockaddr buffer with enough
space for the port string to be copied into sa_data[] and uses that
combined length to determine how much should be copied at the end of the
function.
This fixes a crash when using xwayland which uses ListenOnOpenFD() that
will call _XSERVTransReopenCOTSServer() with a short port string like
":1".
Signed-off-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/Xtranssock.c b/Xtranssock.c
index 66f9862..dfa41cf 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -458,6 +458,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
XtransConnInfo ciptr;
int portlen;
struct sockaddr *addr;
+ size_t addrlen;
prmsg (3,"SocketReopen(%d,%d,%s)\n", type, fd, port);
@@ -488,26 +489,27 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
ciptr->fd = fd;
- if ((addr = calloc (1, portlen + 2)) == NULL) {
+ addrlen = portlen + offsetof(struct sockaddr, sa_data);
+ if ((addr = calloc (1, addrlen)) == NULL) {
prmsg (1, "SocketReopen: malloc(addr) failed\n");
free (ciptr);
return NULL;
}
ciptr->addr = (char *) addr;
- ciptr->addrlen = portlen + 2;
+ ciptr->addrlen = addrlen;
- if ((ciptr->peeraddr = calloc (1, portlen + 2)) == NULL) {
+ if ((ciptr->peeraddr = calloc (1, addrlen)) == NULL) {
prmsg (1, "SocketReopen: malloc(portaddr) failed\n");
free (addr);
free (ciptr);
return NULL;
}
- ciptr->peeraddrlen = portlen + 2;
+ ciptr->peeraddrlen = addrlen;
/* Initialize ciptr structure as if it were a normally-opened unix socket */
ciptr->flags = TRANS_LOCAL | TRANS_NOUNLINK;
#ifdef BSD44SOCKETS
- addr->sa_len = portlen + 1;
+ addr->sa_len = addrlen;
#endif
addr->sa_family = AF_UNIX;
#ifdef HAS_STRLCPY
@@ -516,7 +518,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
strncpy(addr->sa_data, port, portlen);
#endif
ciptr->family = AF_UNIX;
- memcpy(ciptr->peeraddr, ciptr->addr, sizeof(struct sockaddr));
+ memcpy(ciptr->peeraddr, ciptr->addr, addrlen);
ciptr->port = rindex(addr->sa_data, ':');
if (ciptr->port == NULL) {
if (is_numeric(addr->sa_data)) {
commit a04a45cb94f7f569e6dd77df93258fa167d0a4ea
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Wed Nov 30 18:40:46 2011 -0800
Remove unnecessary casts on malloc, calloc & free calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
diff --git a/Xtrans.c b/Xtrans.c
index 97de39b..54e3bdc 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -143,7 +143,7 @@ TRANS(FreeConnInfo) (XtransConnInfo ciptr)
if (ciptr->port)
free (ciptr->port);
- free ((char *) ciptr);
+ free (ciptr);
}
@@ -939,7 +939,7 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->addrlen;
- if ((*addrp = (Xtransaddr *) malloc (ciptr->addrlen)) == NULL)
+ if ((*addrp = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,"GetMyAddr: malloc failed\n");
return -1;
@@ -959,7 +959,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->peeraddrlen;
- if ((*addrp = (Xtransaddr *) malloc (ciptr->peeraddrlen)) == NULL)
+ if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL)
{
prmsg (1,"GetPeerAddr: malloc failed\n");
return -1;
@@ -1128,7 +1128,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
if (*count_ret > 0)
{
- if ((*ciptrs_ret = (XtransConnInfo *) malloc (
+ if ((*ciptrs_ret = malloc (
*count_ret * sizeof (XtransConnInfo))) == NULL)
{
return -1;
@@ -1226,7 +1226,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
if (*count_ret > 0)
{
- if ((*ciptrs_ret = (XtransConnInfo *) malloc (
+ if ((*ciptrs_ret = malloc (
*count_ret * sizeof (XtransConnInfo))) == NULL)
{
return -1;
diff --git a/Xtranslcl.c b/Xtranslcl.c
index 925ba01..5beef7c 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -152,7 +152,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
ciptr->family = AF_UNIX;
ciptr->addrlen = sizeof (struct sockaddr_un);
- if ((sunaddr = (struct sockaddr_un *) malloc (ciptr->addrlen)) == NULL)
+ if ((sunaddr = malloc (ciptr->addrlen)) == NULL)
{
prmsg(1,"FillAddrInfo: failed to allocate memory for addr\n");
return 0;
@@ -174,12 +174,11 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
ciptr->peeraddrlen = sizeof (struct sockaddr_un);
- if ((p_sunaddr = (struct sockaddr_un *) malloc (
- ciptr->peeraddrlen)) == NULL)
+ if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL)
{
prmsg(1,
"FillAddrInfo: failed to allocate memory for peer addr\n");
- free ((char *) sunaddr);
+ free (sunaddr);
ciptr->addr = NULL;
return 0;
@@ -613,7 +612,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
close(newfd);
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -623,7 +622,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
newciptr->peeraddrlen=sizeof(struct sockaddr_un);
- if( (sunaddr=(struct sockaddr_un *)malloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (sunaddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
free(newciptr->addr);
close(newfd);
@@ -885,7 +884,7 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->family=ciptr->family;
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,
"NAMEDAccept: failed to allocate memory for pipe addr\n");
close(str.fd);
@@ -896,7 +895,7 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
newciptr->peeraddrlen=newciptr->addrlen;
- if( (newciptr->peeraddr=(char *)malloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,
"NAMEDAccept: failed to allocate memory for peer addr\n");
free(newciptr->addr);
@@ -1223,7 +1222,7 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
*/
newciptr->addrlen=ciptr->addrlen;
- if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) {
+ if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
prmsg(1,
"SCOAccept: failed to allocate memory for peer addr\n");
close(fd);
@@ -1237,7 +1236,7 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
#endif
newciptr->peeraddrlen=newciptr->addrlen;
- if( (newciptr->peeraddr=(char *)malloc(newciptr->peeraddrlen)) == NULL ) {
+ if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
prmsg(1,
"SCOAccept: failed to allocate memory for peer addr\n");
free(newciptr->addr);
@@ -1811,7 +1810,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port)
*/
#endif /* X11_t */
- if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -1885,7 +1884,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por
*/
#endif /* X11_t */
- if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -1939,7 +1938,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd);
- if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
@@ -2171,7 +2170,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
transptr=(LOCALtrans2dev *)ciptr->priv;
- if( (newciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo)))==NULL )
+ if( (newciptr = calloc(1,sizeof(struct _XtransConnInfo)))==NULL )
{
prmsg(1,"LocalAccept: calloc(1,%lu) failed\n",
sizeof(struct _XtransConnInfo));
diff --git a/Xtranssock.c b/Xtranssock.c
index bda2bcc..66f9862 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -315,7 +315,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if ((ciptr->addr = (char *) malloc (namelen)) == NULL)
+ if ((ciptr->addr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketINETGetAddr: Can't allocate space for the addr\n");
@@ -382,7 +382,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if ((ciptr->peeraddr = (char *) malloc (namelen)) == NULL)
+ if ((ciptr->peeraddr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketINETGetPeerAddr: Can't allocate space for the addr\n");
@@ -404,8 +404,7 @@ TRANS(SocketOpen) (int i, int type)
prmsg (3,"SocketOpen(%d,%d)\n", i, type);
- if ((ciptr = (XtransConnInfo) calloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketOpen: malloc failed\n");
return NULL;
@@ -425,7 +424,7 @@ TRANS(SocketOpen) (int i, int type)
prmsg (2, "SocketOpen: socket() failed for %s\n",
Sockettrans2devtab[i].transname);
- free ((char *) ciptr);
+ free (ciptr);
return NULL;
}
@@ -481,8 +480,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
}
#endif /*SOCK_MAXADDRLEN*/
- if ((ciptr = (XtransConnInfo) calloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketReopen: malloc(ciptr) failed\n");
return NULL;
@@ -490,7 +488,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
ciptr->fd = fd;
- if ((addr = (struct sockaddr *) calloc (1, portlen + 2)) == NULL) {
+ if ((addr = calloc (1, portlen + 2)) == NULL) {
prmsg (1, "SocketReopen: malloc(addr) failed\n");
free (ciptr);
return NULL;
@@ -498,7 +496,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
ciptr->addr = (char *) addr;
ciptr->addrlen = portlen + 2;
- if ((ciptr->peeraddr = (char *) calloc (1, portlen + 2)) == NULL) {
+ if ((ciptr->peeraddr = calloc (1, portlen + 2)) == NULL) {
prmsg (1, "SocketReopen: malloc(portaddr) failed\n");
free (addr);
free (ciptr);
@@ -1138,7 +1136,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
namelen = sizeof (sockname); /* this will always make it the same size */
- if ((ciptr->addr = (char *) malloc (namelen)) == NULL)
+ if ((ciptr->addr = malloc (namelen)) == NULL)
{
prmsg (1,
"SocketUNIXCreateListener: Can't allocate space for the addr\n");
@@ -1252,8 +1250,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd);
- if ((newciptr = (XtransConnInfo) calloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketINETAccept: malloc failed\n");
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -1329,8 +1326,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd);
- if ((newciptr = (XtransConnInfo) calloc (
- 1, sizeof(struct _XtransConnInfo))) == NULL)
+ if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
{
prmsg (1, "SocketUNIXAccept: malloc() failed\n");
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -1352,7 +1348,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
* since this is unix domain.
*/
- if ((newciptr->addr = (char *) malloc (ciptr->addrlen)) == NULL)
+ if ((newciptr->addr = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,
"SocketUNIXAccept: Can't allocate space for the addr\n");
@@ -1370,7 +1366,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
newciptr->addrlen = ciptr->addrlen;
memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
- if ((newciptr->peeraddr = (char *) malloc (ciptr->addrlen)) == NULL)
+ if ((newciptr->peeraddr = malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,
"SocketUNIXAccept: Can't allocate space for the addr\n");
@@ -2053,8 +2049,8 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
* since this is unix domain.
*/
- if ((ciptr->addr = (char *) malloc(namelen)) == NULL ||
- (ciptr->peeraddr = (char *) malloc(namelen)) == NULL)
+ if ((ciptr->addr = malloc(namelen)) == NULL ||
+ (ciptr->peeraddr = malloc(namelen)) == NULL)
{
prmsg (1,
"SocketUNIXCreateListener: Can't allocate space for the addr\n");
diff --git a/Xtranstli.c b/Xtranstli.c
index cbb7d4b..397c946 100644
--- a/Xtranstli.c
+++ b/Xtranstli.c
@@ -169,7 +169,7 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr)
if( ciptr->addr )
free(ciptr->addr);
- if( (ciptr->addr=(char *)malloc(netbuf.len)) == NULL )
+ if( (ciptr->addr = malloc(netbuf.len)) == NULL )
{
prmsg(1, "TLIGetAddr: Can't allocate space for the addr\n");
return -1;
@@ -218,7 +218,7 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr)
if( ciptr->peeraddr )
free(ciptr->peeraddr);
- if( (ciptr->peeraddr=(char *)malloc(netbuf.len)) == NULL )
+ if( (ciptr->peeraddr = malloc(netbuf.len)) == NULL )
{
prmsg(1,
"TLIGetPeerAddr: Can't allocate space for the addr\n");
@@ -312,7 +312,7 @@ TRANS(TLIOpen)(char *device)
prmsg(3,"TLIOpen(%s)\n", device);
- if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1, "TLIOpen: calloc failed\n");
return NULL;
@@ -345,7 +345,7 @@ TRANS(TLIReopen)(char *device, int fd, char *port)
return NULL;
}
- if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+ if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
{
prmsg(1, "TLIReopen: calloc failed\n");
return NULL;
@@ -720,7 +720,7 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req)
* Everything looks good: fill in the XtransConnInfo structure.
*/
- if( (ciptr->addr=(char *)malloc(ret->addr.len)) == NULL )
+ if( (ciptr->addr = malloc(ret->addr.len)) == NULL )
{
prmsg(1,
"TLICreateListener: Unable to allocate space for the address\n");
diff --git a/Xtransutil.c b/Xtransutil.c
index 4128990..52c937b 100644
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -197,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;
@@ -212,7 +212,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
else
{
if (*addrp)
- free ((char *) *addrp);
+ free (*addrp);
*addrp = NULL;
*addrlenp = 0;
}
@@ -255,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);
@@ -285,7 +285,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
portnum = ntohs (saddr->sin_port);
snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum);
- networkId = (char *) malloc (3 + strlen (transName) +
+ networkId = malloc (3 + strlen (transName) +
strlen (hostnamebuf) + strlen (portnumbuf));
sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
break;
@@ -418,8 +418,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)
commit a0bfb4fefd20b396e3d88eff0c60602fc436dad5
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Wed Nov 30 18:11:15 2011 -0800
Replace malloc(strlen)+strcpy with strdup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
diff --git a/Xtrans.c b/Xtrans.c
index 007b54f..97de39b 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -212,8 +212,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
/* Copy the string so it can be changed */
- tmpptr = mybuf = (char *) malloc (strlen (address) + 1);
- strcpy (mybuf, address);
+ tmpptr = mybuf = strdup (address);
/* Parse the string to get each component */
@@ -346,7 +345,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
* string space for them.
*/
- if ((*protocol = (char *) malloc(strlen (_protocol) + 1)) == NULL)
+ if ((*protocol = strdup (_protocol)) == NULL)
{
/* Malloc failed */
*port = NULL;
@@ -355,10 +354,8 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
free (tmpptr);
return 0;
}
- else
- strcpy (*protocol, _protocol);
- if ((*host = (char *) malloc (strlen (_host) + 1)) == NULL)
+ if ((*host = strdup (_host)) == NULL)
{
/* Malloc failed */
*port = NULL;
@@ -367,11 +364,9 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
*protocol = NULL;
free (tmpptr);
return 0;
- }
- else
- strcpy (*host, _host);
+ }
- if ((*port = (char *) malloc (strlen (_port) + 1)) == NULL)
+ if ((*port = strdup (_port)) == NULL)
{
/* Malloc failed */
*port = NULL;
@@ -382,8 +377,6 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
free (tmpptr);
return 0;
}
- else
- strcpy (*port, _port);
free (tmpptr);
@@ -523,15 +516,13 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
return NULL;
}
- if ((save_port = (char *) malloc (strlen (port) + 1)) == NULL)
+ if ((save_port = strdup (port)) == NULL)
{
prmsg (1,"Reopen: Unable to malloc port string\n");
return NULL;
}
- strcpy (save_port, port);
-
/* Get a new XtransConnInfo object */
switch (type)
@@ -653,13 +644,10 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr,
*trans_id = Xtransports[i].transport_id;
*fd = ciptr->fd;
- if ((*port = (char *) malloc (strlen (ciptr->port) + 1)) == NULL)
+ if ((*port = strdup (ciptr->port)) == NULL)
return 0;
else
- {
- strcpy (*port, ciptr->port);
return 1;
- }
}
return 0;
diff --git a/Xtranslcl.c b/Xtranslcl.c
index 8a5e718..925ba01 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -1671,17 +1671,13 @@ TRANS(LocalInitTransports)(const char *protocol)
if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") )
{
- workingXLOCAL=freeXLOCAL=(char *)malloc (strlen (protocol) + 1);
- if (workingXLOCAL)
- strcpy (workingXLOCAL, protocol);
+ workingXLOCAL = freeXLOCAL = strdup (protocol);
}
else {
XLOCAL=(char *)getenv("XLOCAL");
if(XLOCAL==NULL)
XLOCAL=DEF_XLOCAL;
- workingXLOCAL=freeXLOCAL=(char *)malloc (strlen (XLOCAL) + 1);
- if (workingXLOCAL)
- strcpy (workingXLOCAL, XLOCAL);
+ workingXLOCAL = freeXLOCAL = strdup (XLOCAL);
}
}
commit b89e1b45198c48996750b5da3d715c10f974243f
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Wed Nov 30 18:05:05 2011 -0800
Finish conversion to standard C allocation functions
Commit 4ac40cd5451 started this, by no longer special casing the
xserver to include it's former custom allocation functions, this
just takes the remaining #defines and pre-substitutes them into
the code.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/Xtrans.c b/Xtrans.c
index 6973ca5..007b54f 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -135,15 +135,15 @@ TRANS(FreeConnInfo) (XtransConnInfo ciptr)
prmsg (3,"FreeConnInfo(%p)\n", ciptr);
if (ciptr->addr)
- xfree (ciptr->addr);
+ free (ciptr->addr);
if (ciptr->peeraddr)
- xfree (ciptr->peeraddr);
+ free (ciptr->peeraddr);
if (ciptr->port)
- xfree (ciptr->port);
+ free (ciptr->port);
- xfree ((char *) ciptr);
+ free ((char *) ciptr);
}
@@ -212,7 +212,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
/* Copy the string so it can be changed */
- tmpptr = mybuf = (char *) xalloc (strlen (address) + 1);
+ tmpptr = mybuf = (char *) malloc (strlen (address) + 1);
strcpy (mybuf, address);
/* Parse the string to get each component */
@@ -229,7 +229,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
*protocol = NULL;
*host = NULL;
*port = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
@@ -279,7 +279,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
*protocol = NULL;
*host = NULL;
*port = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
@@ -346,46 +346,46 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
* string space for them.
*/
- if ((*protocol = (char *) xalloc(strlen (_protocol) + 1)) == NULL)
+ if ((*protocol = (char *) malloc(strlen (_protocol) + 1)) == NULL)
{
/* Malloc failed */
*port = NULL;
*host = NULL;
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
else
strcpy (*protocol, _protocol);
- if ((*host = (char *) xalloc (strlen (_host) + 1)) == NULL)
+ if ((*host = (char *) malloc (strlen (_host) + 1)) == NULL)
{
/* Malloc failed */
*port = NULL;
*host = NULL;
- xfree (*protocol);
+ free (*protocol);
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
else
strcpy (*host, _host);
- if ((*port = (char *) xalloc (strlen (_port) + 1)) == NULL)
+ if ((*port = (char *) malloc (strlen (_port) + 1)) == NULL)
{
/* Malloc failed */
*port = NULL;
- xfree (*host);
+ free (*host);
*host = NULL;
- xfree (*protocol);
+ free (*protocol);
*protocol = NULL;
- xfree (tmpptr);
+ free (tmpptr);
return 0;
}
else
strcpy (*port, _port);
- xfree (tmpptr);
+ free (tmpptr);
return 1;
}
@@ -430,9 +430,9 @@ TRANS(Open) (int type, char *address)
prmsg (1,"Open: Unable to find transport for %s\n",
protocol);
- xfree (protocol);
- xfree (host);
- xfree (port);
+ free (protocol);
+ free (host);
+ free (port);
return NULL;
}
@@ -471,17 +471,17 @@ TRANS(Open) (int type, char *address)
prmsg (1,"Open: transport open failed for %s/%s:%s\n",
protocol, host, port);
}
- xfree (protocol);
- xfree (host);
- xfree (port);
+ free (protocol);
+ free (host);
+ free (port);
return NULL;
}
ciptr->transptr = thistrans;
ciptr->port = port; /* We need this for TRANS(Reopen) */
- xfree (protocol);
- xfree (host);
+ free (protocol);
+ free (host);
return ciptr;
}
@@ -523,7 +523,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
return NULL;
}
- if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL)
+ if ((save_port = (char *) malloc (strlen (port) + 1)) == NULL)
{
prmsg (1,"Reopen: Unable to malloc port string\n");
@@ -549,7 +549,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
if (ciptr == NULL)
{
prmsg (1,"Reopen: transport open failed\n");
- xfree(save_port);
+ free (save_port);
return NULL;
}
@@ -653,7 +653,7 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr,
*trans_id = Xtransports[i].transport_id;
*fd = ciptr->fd;
- if ((*port = (char *) xalloc (strlen (ciptr->port) + 1)) == NULL)
+ if ((*port = (char *) malloc (strlen (ciptr->port) + 1)) == NULL)
return 0;
else
{
@@ -844,16 +844,16 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address)
{
prmsg (1,"Connect: Missing port specification in %s\n",
address);
- if (protocol) xfree (protocol);
- if (host) xfree (host);
+ if (protocol) free (protocol);
+ if (host) free (host);
return -1;
}
ret = ciptr->transptr->Connect (ciptr, host, port);
- if (protocol) xfree (protocol);
- if (host) xfree (host);
- if (port) xfree (port);
+ if (protocol) free (protocol);
+ if (host) free (host);
+ if (port) free (port);
return ret;
}
@@ -951,7 +951,7 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->addrlen;
- if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL)
+ if ((*addrp = (Xtransaddr *) malloc (ciptr->addrlen)) == NULL)
{
prmsg (1,"GetMyAddr: malloc failed\n");
return -1;
@@ -971,7 +971,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
*familyp = ciptr->family;
*addrlenp = ciptr->peeraddrlen;
- if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL)
+ if ((*addrp = (Xtransaddr *) malloc (ciptr->peeraddrlen)) == NULL)
{
prmsg (1,"GetPeerAddr: malloc failed\n");
return -1;
Reply to: