summaryrefslogtreecommitdiff
path: root/xserver/os
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2010-12-05 15:36:12 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2010-12-05 15:36:12 +0000
commita90ee792d96752ad1b71b9ada922fa6afe478c99 (patch)
tree6143b00f7646951d23dfe2a4fe2992ca40b77069 /xserver/os
parentbc97d4ecc0aa9e1b823565b07282f848700bd11a (diff)
Upgrade to xorg-server 1.9.2.
Tested by ajacoutot@, krw@, shadchin@ and jasper@ on various configurations including multihead with both zaphod and xrandr.
Diffstat (limited to 'xserver/os')
-rw-r--r--xserver/os/Makefile.in30
-rw-r--r--xserver/os/WaitFor.c6
-rw-r--r--xserver/os/access.c75
-rw-r--r--xserver/os/auth.c15
-rw-r--r--xserver/os/connection.c36
-rw-r--r--xserver/os/io.c99
-rw-r--r--xserver/os/log.c10
-rw-r--r--xserver/os/mitauth.c22
-rw-r--r--xserver/os/osdep.h24
-rw-r--r--xserver/os/osinit.c5
-rw-r--r--xserver/os/privsep.c12
-rw-r--r--xserver/os/rpcauth.c14
-rw-r--r--xserver/os/strcasecmp.c2
-rw-r--r--xserver/os/strcasestr.c2
-rw-r--r--xserver/os/strlcpy.c2
-rw-r--r--xserver/os/utils.c237
-rw-r--r--xserver/os/xdmauth.c62
-rw-r--r--xserver/os/xdmcp.c80
-rw-r--r--xserver/os/xprintf.c4
-rw-r--r--xserver/os/xsha1.c20
20 files changed, 341 insertions, 416 deletions
diff --git a/xserver/os/Makefile.in b/xserver/os/Makefile.in
index 1ae10aaf0..7a9acd783 100644
--- a/xserver/os/Makefile.in
+++ b/xserver/os/Makefile.in
@@ -137,10 +137,6 @@ BUILDDOCS_TRUE = @BUILDDOCS_TRUE@
BUILD_DATE = @BUILD_DATE@
BUILD_KDRIVEFBDEVLIB_FALSE = @BUILD_KDRIVEFBDEVLIB_FALSE@
BUILD_KDRIVEFBDEVLIB_TRUE = @BUILD_KDRIVEFBDEVLIB_TRUE@
-BUILD_LINUXDOC_FALSE = @BUILD_LINUXDOC_FALSE@
-BUILD_LINUXDOC_TRUE = @BUILD_LINUXDOC_TRUE@
-BUILD_PDFDOC_FALSE = @BUILD_PDFDOC_FALSE@
-BUILD_PDFDOC_TRUE = @BUILD_PDFDOC_TRUE@
BUILD_TIME = @BUILD_TIME@
CC = @CC@
CCAS = @CCAS@
@@ -228,6 +224,8 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ENABLE_DEVEL_DOCS_FALSE = @ENABLE_DEVEL_DOCS_FALSE@
+ENABLE_DEVEL_DOCS_TRUE = @ENABLE_DEVEL_DOCS_TRUE@
EXEEXT = @EXEEXT@
F77 = @F77@
FBDEVHW_FALSE = @FBDEVHW_FALSE@
@@ -242,6 +240,7 @@ FONTOTFDIR = @FONTOTFDIR@
FONTROOTDIR = @FONTROOTDIR@
FONTTTFDIR = @FONTTTFDIR@
FONTTYPE1DIR = @FONTTYPE1DIR@
+FOP = @FOP@
FREEBSD_KLDLOAD_FALSE = @FREEBSD_KLDLOAD_FALSE@
FREEBSD_KLDLOAD_TRUE = @FREEBSD_KLDLOAD_TRUE@
GLIB_CFLAGS = @GLIB_CFLAGS@
@@ -259,10 +258,14 @@ HAVE_DBUS_FALSE = @HAVE_DBUS_FALSE@
HAVE_DBUS_TRUE = @HAVE_DBUS_TRUE@
HAVE_DOXYGEN_FALSE = @HAVE_DOXYGEN_FALSE@
HAVE_DOXYGEN_TRUE = @HAVE_DOXYGEN_TRUE@
-HAVE_PS2PDF_FALSE = @HAVE_PS2PDF_FALSE@
-HAVE_PS2PDF_TRUE = @HAVE_PS2PDF_TRUE@
+HAVE_FOP_FALSE = @HAVE_FOP_FALSE@
+HAVE_FOP_TRUE = @HAVE_FOP_TRUE@
HAVE_STYLESHEETS_FALSE = @HAVE_STYLESHEETS_FALSE@
HAVE_STYLESHEETS_TRUE = @HAVE_STYLESHEETS_TRUE@
+HAVE_XMLTO_FALSE = @HAVE_XMLTO_FALSE@
+HAVE_XMLTO_TEXT_FALSE = @HAVE_XMLTO_TEXT_FALSE@
+HAVE_XMLTO_TEXT_TRUE = @HAVE_XMLTO_TEXT_TRUE@
+HAVE_XMLTO_TRUE = @HAVE_XMLTO_TRUE@
HP300_VIDEO_FALSE = @HP300_VIDEO_FALSE@
HP300_VIDEO_TRUE = @HP300_VIDEO_TRUE@
HPPA_VIDEO_FALSE = @HPPA_VIDEO_FALSE@
@@ -318,10 +321,11 @@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
+LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@
+LIBSHA1_LIBS = @LIBSHA1_LIBS@
LIBTOOL = @LIBTOOL@
LIB_MAN_DIR = @LIB_MAN_DIR@
LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINUXDOC = @LINUXDOC@
LINUX_ALPHA_FALSE = @LINUX_ALPHA_FALSE@
LINUX_ALPHA_TRUE = @LINUX_ALPHA_TRUE@
LINUX_IA64_FALSE = @LINUX_IA64_FALSE@
@@ -339,17 +343,11 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAIN_LIB = @MAIN_LIB@
MAKEINFO = @MAKEINFO@
-MAKE_HTML = @MAKE_HTML@
-MAKE_PDF = @MAKE_PDF@
-MAKE_PS = @MAKE_PS@
-MAKE_TEXT = @MAKE_TEXT@
MAN_SUBSTS = @MAN_SUBSTS@
MISC_MAN_DIR = @MISC_MAN_DIR@
MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
MITSHM_FALSE = @MITSHM_FALSE@
MITSHM_TRUE = @MITSHM_TRUE@
-MULTIBUFFER_FALSE = @MULTIBUFFER_FALSE@
-MULTIBUFFER_TRUE = @MULTIBUFFER_TRUE@
NEED_STRLCAT_FALSE = @NEED_STRLCAT_FALSE@
NEED_STRLCAT_TRUE = @NEED_STRLCAT_TRUE@
NEED_VSNPRINTF_FALSE = @NEED_VSNPRINTF_FALSE@
@@ -376,20 +374,23 @@ PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
PCIACCESS_LIBS = @PCIACCESS_LIBS@
PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
PERL = @PERL@
+PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
+PIXMAN_LIBS = @PIXMAN_LIBS@
PKG_CONFIG = @PKG_CONFIG@
PPC_VIDEO_FALSE = @PPC_VIDEO_FALSE@
PPC_VIDEO_TRUE = @PPC_VIDEO_TRUE@
PROJECTROOT = @PROJECTROOT@
-PS2PDF = @PS2PDF@
RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
RECORD_FALSE = @RECORD_FALSE@
RECORD_TRUE = @RECORD_TRUE@
+RELEASE_DATE = @RELEASE_DATE@
RES_FALSE = @RES_FALSE@
RES_TRUE = @RES_TRUE@
SCREENSAVER_FALSE = @SCREENSAVER_FALSE@
SCREENSAVER_TRUE = @SCREENSAVER_TRUE@
+SDK_REQUIRED_MODULES = @SDK_REQUIRED_MODULES@
SECURE_RPC_FALSE = @SECURE_RPC_FALSE@
SECURE_RPC_TRUE = @SECURE_RPC_TRUE@
SED = @SED@
@@ -481,6 +482,7 @@ XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
XLIB_CFLAGS = @XLIB_CFLAGS@
XLIB_LIBS = @XLIB_LIBS@
+XMLTO = @XMLTO@
XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
XNEST_FALSE = @XNEST_FALSE@
diff --git a/xserver/os/WaitFor.c b/xserver/os/WaitFor.c
index dfe85e515..e66300490 100644
--- a/xserver/os/WaitFor.c
+++ b/xserver/os/WaitFor.c
@@ -431,7 +431,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
if (!timer)
{
- timer = xalloc(sizeof(struct _OsTimerRec));
+ timer = malloc(sizeof(struct _OsTimerRec));
if (!timer)
return NULL;
}
@@ -516,7 +516,7 @@ TimerFree(OsTimerPtr timer)
if (!timer)
return;
TimerCancel(timer);
- xfree(timer);
+ free(timer);
}
void
@@ -536,7 +536,7 @@ TimerInit(void)
while ((timer = timers))
{
timers = timer->next;
- xfree(timer);
+ free(timer);
}
}
diff --git a/xserver/os/access.c b/xserver/os/access.c
index 3572da0c9..027925927 100644
--- a/xserver/os/access.c
+++ b/xserver/os/access.c
@@ -215,11 +215,11 @@ static int ConvertAddr(struct sockaddr * /*saddr*/,
pointer * /*addr*/);
static int CheckAddr(int /*family*/,
- pointer /*pAddr*/,
+ const void * /*pAddr*/,
unsigned /*length*/);
static Bool NewHost(int /*family*/,
- pointer /*addr*/,
+ const void * /*addr*/,
int /*len*/,
int /* addingLocalHosts */);
@@ -238,12 +238,12 @@ typedef struct _host {
int requested;
} HOST;
-#define MakeHost(h,l) (h)=xalloc(sizeof *(h)+(l));\
+#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\
if (h) { \
(h)->addr=(unsigned char *) ((h) + 1);\
(h)->requested = FALSE; \
}
-#define FreeHost(h) xfree(h)
+#define FreeHost(h) free(h)
static HOST *selfhosts = NULL;
static HOST *validhosts = NULL;
static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
@@ -311,7 +311,7 @@ ifioctl (int fd, int cmd, char *arg)
struct strioctl ioc;
int ret;
- bzero((char *) &ioc, sizeof(ioc));
+ memset((char *) &ioc, 0, sizeof(ioc));
ioc.ic_cmd = cmd;
ioc.ic_timout = 0;
if (cmd == SIOCGIFCONF)
@@ -329,7 +329,7 @@ ifioctl (int fd, int cmd, char *arg)
#ifdef SVR4
((struct ifconf *) arg)->ifc_len = ioc.ic_len;
#endif
- return(ret);
+ return ret;
}
#else /* Case sun, SCO325 and others */
#define ifioctl ioctl
@@ -587,7 +587,7 @@ DefineSelf (int fd)
Error ("Getting interface count");
if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
len = ifn.lifn_count * sizeof(struct lifreq);
- bufptr = xalloc(len);
+ bufptr = malloc(len);
}
#endif
@@ -1038,7 +1038,7 @@ ResetHosts (char *display)
len = sizeof(saddr.sa);
if (ConvertAddr (&saddr.sa, &len, (pointer *)&addr) == FamilyDECnet)
{
- bzero ((char *) &dnaddr, sizeof (dnaddr));
+ memset((char *) &dnaddr, 0, sizeof (dnaddr));
dnaddr.a_len = np->n_length;
acopy (np->n_addr, dnaddr.a_addr, np->n_length);
dnaddrp = &dnaddr;
@@ -1123,6 +1123,11 @@ Bool LocalClient(ClientPtr client)
pointer addr;
register HOST *host;
+ if (!client->osPrivate)
+ return FALSE;
+ if (!((OsCommPtr)client->osPrivate)->trans_conn)
+ return FALSE;
+
if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
&notused, &alen, &from))
{
@@ -1130,12 +1135,12 @@ Bool LocalClient(ClientPtr client)
&alen, (pointer *)&addr);
if (family == -1)
{
- xfree (from);
+ free(from);
return FALSE;
}
if (family == FamilyLocal)
{
- xfree (from);
+ free(from);
return TRUE;
}
for (host = selfhosts; host; host = host->next)
@@ -1143,7 +1148,7 @@ Bool LocalClient(ClientPtr client)
if (addrEqual (family, addr, alen, host))
return TRUE;
}
- xfree (from);
+ free(from);
}
return FALSE;
}
@@ -1213,7 +1218,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
}
#endif
- *lccp = Xcalloc(sizeof(LocalClientCredRec));
+ *lccp = calloc(1, sizeof(LocalClientCredRec));
if (*lccp == NULL)
return -1;
lcc = *lccp;
@@ -1249,7 +1254,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
#endif
lcc->nSuppGids = ucred_getgroups(peercred, &gids);
if (lcc->nSuppGids > 0) {
- lcc->pSuppGids = Xcalloc((lcc->nSuppGids) * sizeof(int));
+ lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
if (lcc->pSuppGids == NULL) {
lcc->nSuppGids = 0;
} else {
@@ -1286,9 +1291,9 @@ FreeLocalClientCreds(LocalClientCredRec *lcc)
{
if (lcc != NULL) {
if (lcc->nSuppGids > 0) {
- Xfree(lcc->pSuppGids);
+ free(lcc->pSuppGids);
}
- Xfree(lcc);
+ free(lcc);
}
}
@@ -1315,7 +1320,7 @@ int
AddHost (ClientPtr client,
int family,
unsigned length, /* of bytes in pAddr */
- pointer pAddr)
+ const void * pAddr)
{
int rc, len;
@@ -1343,13 +1348,13 @@ AddHost (ClientPtr client,
if ((len = CheckAddr (family, pAddr, length)) < 0)
{
client->errorValue = length;
- return (BadValue);
+ return BadValue;
}
break;
case FamilyLocal:
default:
client->errorValue = family;
- return (BadValue);
+ return BadValue;
}
if (NewHost (family, pAddr, len, FALSE))
return Success;
@@ -1376,7 +1381,7 @@ ForEachHostInFamily (int family,
* called when starting or resetting the server */
static Bool
NewHost (int family,
- pointer addr,
+ const void * addr,
int len,
int addingLocalHosts)
{
@@ -1441,13 +1446,13 @@ RemoveHost (
if ((len = CheckAddr (family, pAddr, length)) < 0)
{
client->errorValue = length;
- return(BadValue);
+ return BadValue;
}
break;
case FamilyLocal:
default:
client->errorValue = family;
- return(BadValue);
+ return BadValue;
}
for (prev = &validhosts;
(host = *prev) && (!addrEqual (family, pAddr, len, host));
@@ -1458,7 +1463,7 @@ RemoveHost (
*prev = host->next;
FreeHost (host);
}
- return (Success);
+ return Success;
}
/* Get all hosts in the access control list */
@@ -1483,10 +1488,10 @@ GetHosts (
}
if (n)
{
- *data = ptr = xalloc (n);
+ *data = ptr = malloc(n);
if (!ptr)
{
- return(BadAlloc);
+ return BadAlloc;
}
for (host = validhosts; host; host = host->next)
{
@@ -1502,7 +1507,7 @@ GetHosts (
}
*pnHosts = nHosts;
*pLen = n;
- return(Success);
+ return Success;
}
/* Check for valid address family and length, and return address length. */
@@ -1511,7 +1516,7 @@ GetHosts (
static int
CheckAddr (
int family,
- pointer pAddr,
+ const void * pAddr,
unsigned length)
{
int len;
@@ -1555,7 +1560,7 @@ CheckAddr (
default:
len = -1;
}
- return (len);
+ return len;
}
/* Check if a host is not in the access control list.
@@ -1572,7 +1577,7 @@ InvalidHost (
register HOST *selfhost, *host;
if (!AccessEnabled) /* just let them in */
- return(0);
+ return 0;
family = ConvertAddr (saddr, &len, (pointer *)&addr);
if (family == -1)
return 1;
@@ -1600,15 +1605,15 @@ InvalidHost (
{
if ((host->family == FamilyServerInterpreted)) {
if (siAddrMatch (family, addr, len, host, client)) {
- return (0);
+ return 0;
}
} else {
if (addrEqual (family, addr, len, host))
- return (0);
+ return 0;
}
}
- return (1);
+ return 1;
}
static int
@@ -1618,7 +1623,7 @@ ConvertAddr (
pointer *addr)
{
if (*len == 0)
- return (FamilyLocal);
+ return FamilyLocal;
switch (saddr->sa_family)
{
case AF_UNSPEC:
@@ -1742,7 +1747,7 @@ siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
}
}
- s = xalloc(sizeof(struct siType));
+ s = malloc(sizeof(struct siType));
if (s == NULL)
return BadAlloc;
@@ -2084,7 +2089,7 @@ static Bool
siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
{
Bool parsedOK = FALSE;
- char *addrbuf = xalloc(len + 1);
+ char *addrbuf = malloc(len + 1);
if (addrbuf == NULL) {
return FALSE;
@@ -2118,7 +2123,7 @@ siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
}
}
- xfree(addrbuf);
+ free(addrbuf);
return parsedOK;
}
diff --git a/xserver/os/auth.c b/xserver/os/auth.c
index a852e1c3b..768575139 100644
--- a/xserver/os/auth.c
+++ b/xserver/os/auth.c
@@ -159,9 +159,9 @@ RegisterAuthorizations (void)
XID
CheckAuthorization (
unsigned int name_length,
- char *name,
+ const char *name,
unsigned int data_length,
- char *data,
+ const char *data,
ClientPtr client,
char **reason) /* failure message. NULL for default msg */
{
@@ -256,9 +256,9 @@ AuthorizationFromID (
int
RemoveAuthorization (
unsigned short name_length,
- char *name,
+ const char *name,
unsigned short data_length,
- char *data)
+ const char *data)
{
int i;
@@ -274,7 +274,8 @@ RemoveAuthorization (
}
int
-AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *data)
+AddAuthorization (unsigned name_length, const char *name,
+ unsigned data_length, char *data)
{
int i;
@@ -294,9 +295,9 @@ AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *
XID
GenerateAuthorization(
unsigned name_length,
- char *name,
+ const char *name,
unsigned data_length,
- char *data,
+ const char *data,
unsigned *data_length_return,
char **data_return)
{
diff --git a/xserver/os/connection.c b/xserver/os/connection.c
index 37dd399a1..6f7981bac 100644
--- a/xserver/os/connection.c
+++ b/xserver/os/connection.c
@@ -183,7 +183,7 @@ struct _ct_node *ct_head[256];
void InitConnectionTranslation(void)
{
- bzero(ct_head, sizeof(ct_head));
+ memset(ct_head, 0, sizeof(ct_head));
}
int GetConnectionTranslation(int conn)
@@ -226,7 +226,7 @@ void SetConnectionTranslation(int conn, int client)
}
node = &((*node)->next);
}
- *node = xalloc(sizeof(struct _ct_node));
+ *node = malloc(sizeof(struct _ct_node));
(*node)->next = NULL;
(*node)->key = conn;
(*node)->value = client;
@@ -244,7 +244,7 @@ void ClearConnectionTranslation(void)
{
struct _ct_node *temp = node;
node = node->next;
- xfree(temp);
+ free(temp);
}
}
}
@@ -267,7 +267,7 @@ lookup_trans_conn (int fd)
return ListenTransConns[i];
}
- return (NULL);
+ return NULL;
}
/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
@@ -401,7 +401,7 @@ CreateWellKnownSockets(void)
}
else
{
- ListenTransFds = xalloc (ListenTransCount * sizeof (int));
+ ListenTransFds = malloc(ListenTransCount * sizeof (int));
for (i = 0; i < ListenTransCount; i++)
{
@@ -683,7 +683,7 @@ ClientAuthorized(ClientPtr client,
proto_n, auth_proto, auth_id);
}
- xfree (from);
+ free(from);
}
if (auth_id == (XID) ~0L) {
@@ -705,7 +705,7 @@ ClientAuthorized(ClientPtr client,
AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
proto_n, auth_proto, auth_id);
- xfree (from);
+ free(from);
}
}
priv->auth_id = auth_id;
@@ -741,7 +741,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
#endif
)
return NullClient;
- oc = xalloc(sizeof(OsCommRec));
+ oc = malloc(sizeof(OsCommRec));
if (!oc)
return NullClient;
oc->trans_conn = trans_conn;
@@ -752,7 +752,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
oc->conn_time = conn_time;
if (!(client = NextAvailableClient((pointer)oc)))
{
- xfree (oc);
+ free(oc);
return NullClient;
}
#if !defined(WIN32)
@@ -1037,6 +1037,9 @@ CloseDownConnection(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ if (FlushCallback)
+ CallCallbacks(&FlushCallback, NULL);
+
if (oc->output && oc->output->count)
FlushClient(client, oc, (char *)NULL, 0);
#ifdef XDMCP
@@ -1044,7 +1047,7 @@ CloseDownConnection(ClientPtr client)
#endif
CloseDownFileDescriptor(oc);
FreeOsBuffers(oc);
- xfree(client->osPrivate);
+ free(client->osPrivate);
client->osPrivate = (pointer)NULL;
if (auditTrailLevel > 1)
AuditF("client %d disconnected\n", client->index);
@@ -1151,6 +1154,10 @@ IgnoreClient (ClientPtr client)
OsCommPtr oc = (OsCommPtr)client->osPrivate;
int connection = oc->fd;
+ client->ignoreCount++;
+ if (client->ignoreCount > 1)
+ return;
+
isItTimeToYield = TRUE;
if (!GrabInProgress || FD_ISSET(connection, &AllClients))
{
@@ -1185,6 +1192,11 @@ AttendClient (ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
int connection = oc->fd;
+
+ client->ignoreCount--;
+ if (client->ignoreCount)
+ return;
+
if (!GrabInProgress || GrabInProgress == client->index ||
FD_ISSET(connection, &GrabImperviousClients))
{
@@ -1280,8 +1292,8 @@ void ListenOnOpenFD(int fd, int noxauth) {
ciptr->flags = ciptr->flags | TRANS_NOXAUTH;
/* Allocate space to store it */
- ListenTransFds = (int *) xrealloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
- ListenTransConns = (XtransConnInfo *) xrealloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
+ ListenTransFds = (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
+ ListenTransConns = (XtransConnInfo *) realloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
/* Store it */
ListenTransConns[ListenTransCount] = ciptr;
diff --git a/xserver/os/io.c b/xserver/os/io.c
index 64b64ae75..fb9f76207 100644
--- a/xserver/os/io.c
+++ b/xserver/os/io.c
@@ -215,8 +215,8 @@ ReadRequestFromClient(ClientPtr client)
register ConnectionInputPtr aci = AvailableInput->input;
if (aci->size > BUFWATERMARK)
{
- xfree(aci->buffer);
- xfree(aci);
+ free(aci->buffer);
+ free(aci);
}
else
{
@@ -251,7 +251,14 @@ ReadRequestFromClient(ClientPtr client)
need_header = FALSE;
move_header = FALSE;
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
- if (gotnow < sizeof(xReq))
+
+ if (oci->ignoreBytes > 0) {
+ if (oci->ignoreBytes > oci->size)
+ needed = oci->size;
+ else
+ needed = oci->ignoreBytes;
+ }
+ else if (gotnow < sizeof(xReq))
{
/* We don't have an entire xReq yet. Can't tell how big
* the request will be until we get the whole xReq.
@@ -294,8 +301,13 @@ ReadRequestFromClient(ClientPtr client)
if (needed > maxBigRequestSize << 2)
{
/* request is too big for us to handle */
- YieldControlDeath();
- return -1;
+ /*
+ * Mark the rest of it as needing to be ignored, and then return
+ * the full size. Dispatch() will turn it into a BadLength error.
+ */
+ oci->ignoreBytes = needed - gotnow;
+ oci->lenLastReq = gotnow;
+ return needed;
}
if ((gotnow == 0) ||
((oci->bufptr - oci->buffer + needed) > oci->size))
@@ -310,7 +322,7 @@ ReadRequestFromClient(ClientPtr client)
/* make buffer bigger to accomodate request */
char *ibuf;
- ibuf = (char *)xrealloc(oci->buffer, needed);
+ ibuf = (char *)realloc(oci->buffer, needed);
if (!ibuf)
{
YieldControlDeath();
@@ -360,7 +372,7 @@ ReadRequestFromClient(ClientPtr client)
{
char *ibuf;
- ibuf = (char *)xrealloc(oci->buffer, BUFSIZE);
+ ibuf = (char *)realloc(oci->buffer, BUFSIZE);
if (ibuf)
{
oci->size = BUFSIZE;
@@ -400,6 +412,14 @@ ReadRequestFromClient(ClientPtr client)
}
oci->lenLastReq = needed;
+ /* If there are bytes to ignore, ignore them now. */
+
+ if (oci->ignoreBytes > 0) {
+ assert(needed == oci->ignoreBytes || needed == oci->size);
+ oci->ignoreBytes -= gotnow;
+ needed = gotnow = 0;
+ }
+
/*
* Check to see if client has at least one whole request in the
* buffer beyond the request we're returning to the caller.
@@ -479,8 +499,8 @@ InsertFakeRequest(ClientPtr client, char *data, int count)
ConnectionInputPtr aci = AvailableInput->input;
if (aci->size > BUFWATERMARK)
{
- xfree(aci->buffer);
- xfree(aci);
+ free(aci->buffer);
+ free(aci);
}
else
{
@@ -506,9 +526,9 @@ InsertFakeRequest(ClientPtr client, char *data, int count)
{
char *ibuf;
- ibuf = (char *)xrealloc(oci->buffer, gotnow + count);
+ ibuf = (char *)realloc(oci->buffer, gotnow + count);
if (!ibuf)
- return(FALSE);
+ return FALSE;
oci->size = gotnow + count;
oci->buffer = ibuf;
oci->bufptr = ibuf + oci->bufcnt - gotnow;
@@ -529,7 +549,7 @@ InsertFakeRequest(ClientPtr client, char *data, int count)
FD_SET(fd, &ClientsWithInput);
else
YieldControlNoInput(fd);
- return(TRUE);
+ return TRUE;
}
/*****************************************************************
@@ -698,15 +718,17 @@ SetCriticalOutputPending(void)
int
WriteToClient (ClientPtr who, int count, const void *__buf)
{
- OsCommPtr oc = (OsCommPtr)who->osPrivate;
- ConnectionOutputPtr oco = oc->output;
+ OsCommPtr oc;
+ ConnectionOutputPtr oco;
int padBytes;
const char *buf = __buf;
#ifdef DEBUG_COMMUNICATION
Bool multicount = FALSE;
#endif
- if (!count)
- return(0);
+ if (!count || !who || who == serverClient || who->clientGone)
+ return 0;
+ oc = who->osPrivate;
+ oco = oc->output;
#ifdef DEBUG_COMMUNICATION
{
char info[128];
@@ -817,6 +839,10 @@ WriteToClient (ClientPtr who, int count, const void *__buf)
CriticalOutputPending = FALSE;
NewOutputPending = FALSE;
}
+
+ if (FlushCallback)
+ CallCallbacks(&FlushCallback, NULL);
+
return FlushClient(who, oc, buf, count);
}
@@ -824,7 +850,7 @@ WriteToClient (ClientPtr who, int count, const void *__buf)
FD_SET(oc->fd, &OutputPending);
memmove((char *)oco->buf + oco->count, buf, count);
oco->count += count + padBytes;
- return(count);
+ return count;
}
/********************
@@ -937,7 +963,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
{
unsigned char *obuf;
- obuf = (unsigned char *)xrealloc(oco->buf,
+ obuf = (unsigned char *)realloc(oco->buf,
notWritten + BUFSIZE);
if (!obuf)
{
@@ -946,7 +972,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
oc->trans_conn = NULL;
MarkClientException(who);
oco->count = 0;
- return(-1);
+ return -1;
}
oco->size = notWritten + BUFSIZE;
oco->buf = obuf;
@@ -979,7 +1005,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
}
MarkClientException(who);
oco->count = 0;
- return(-1);
+ return -1;
}
}
@@ -994,8 +1020,8 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
}
if (oco->size > BUFWATERMARK)
{
- xfree(oco->buf);
- xfree(oco);
+ free(oco->buf);
+ free(oco);
}
else
{
@@ -1011,19 +1037,20 @@ AllocateInputBuffer(void)
{
ConnectionInputPtr oci;
- oci = xalloc(sizeof(ConnectionInput));
+ oci = malloc(sizeof(ConnectionInput));
if (!oci)
return NULL;
- oci->buffer = xalloc(BUFSIZE);
+ oci->buffer = malloc(BUFSIZE);
if (!oci->buffer)
{
- xfree(oci);
+ free(oci);
return NULL;
}
oci->size = BUFSIZE;
oci->bufptr = oci->buffer;
oci->bufcnt = 0;
oci->lenLastReq = 0;
+ oci->ignoreBytes = 0;
return oci;
}
@@ -1032,13 +1059,13 @@ AllocateOutputBuffer(void)
{
ConnectionOutputPtr oco;
- oco = xalloc(sizeof(ConnectionOutput));
+ oco = malloc(sizeof(ConnectionOutput));
if (!oco)
return NULL;
- oco->buf = xcalloc(1, BUFSIZE);
+ oco->buf = calloc(1, BUFSIZE);
if (!oco->buf)
{
- xfree(oco);
+ free(oco);
return NULL;
}
oco->size = BUFSIZE;
@@ -1058,8 +1085,8 @@ FreeOsBuffers(OsCommPtr oc)
{
if (FreeInputs)
{
- xfree(oci->buffer);
- xfree(oci);
+ free(oci->buffer);
+ free(oci);
}
else
{
@@ -1074,8 +1101,8 @@ FreeOsBuffers(OsCommPtr oc)
{
if (FreeOutputs)
{
- xfree(oco->buf);
- xfree(oco);
+ free(oco->buf);
+ free(oco);
}
else
{
@@ -1095,13 +1122,13 @@ ResetOsBuffers(void)
while ((oci = FreeInputs))
{
FreeInputs = oci->next;
- xfree(oci->buffer);
- xfree(oci);
+ free(oci->buffer);
+ free(oci);
}
while ((oco = FreeOutputs))
{
FreeOutputs = oco->next;
- xfree(oco->buf);
- xfree(oco);
+ free(oco->buf);
+ free(oco);
}
}
diff --git a/xserver/os/log.c b/xserver/os/log.c
index d4455fddf..e5eae148b 100644
--- a/xserver/os/log.c
+++ b/xserver/os/log.c
@@ -228,7 +228,7 @@ LogInit(const char *fname, const char *backup)
* needed.
*/
if (saveBuffer && bufferSize > 0) {
- free(saveBuffer); /* Must be free(), not xfree() */
+ free(saveBuffer); /* Must be free(), not free() */
saveBuffer = NULL;
bufferSize = 0;
}
@@ -305,8 +305,7 @@ LogVWrite(int verb, const char *f, va_list args)
} else if (needBuffer) {
/*
* Note, this code is used before OsInit() has been called, so
- * xalloc() and friends can't be used.
- * And it should not be called inside a signal handler.
+ * malloc() and friends can't be used.
*/
if (len > bufferUnused) {
bufferSize += 1024;
@@ -411,9 +410,8 @@ LogMessage(MessageType type, const char *format, ...)
va_end(ap);
}
-#ifdef __GNUC__
-void AbortServer(void) __attribute__((noreturn));
-#endif
+void
+AbortServer(void) _X_NORETURN;
void
AbortServer(void)
diff --git a/xserver/os/mitauth.c b/xserver/os/mitauth.c
index a7968cbd7..4b8f6e978 100644
--- a/xserver/os/mitauth.c
+++ b/xserver/os/mitauth.c
@@ -50,17 +50,17 @@ static struct auth {
int
MitAddCookie (
unsigned short data_length,
- char *data,
+ const char *data,
XID id)
{
struct auth *new;
- new = xalloc (sizeof (struct auth));
+ new = malloc(sizeof (struct auth));
if (!new)
return 0;
- new->data = xalloc ((unsigned) data_length);
+ new->data = malloc((unsigned) data_length);
if (!new->data) {
- xfree(new);
+ free(new);
return 0;
}
new->next = mit_auth;
@@ -74,7 +74,7 @@ MitAddCookie (
XID
MitCheckCookie (
unsigned short data_length,
- char *data,
+ const char *data,
ClientPtr client,
char **reason)
{
@@ -96,8 +96,8 @@ MitResetCookie (void)
for (auth = mit_auth; auth; auth=next) {
next = auth->next;
- xfree (auth->data);
- xfree (auth);
+ free(auth->data);
+ free(auth);
}
mit_auth = 0;
return 0;
@@ -139,7 +139,7 @@ MitFromID (
int
MitRemoveCookie (
unsigned short data_length,
- char *data)
+ const char *data)
{
struct auth *auth, *prev;
@@ -152,8 +152,8 @@ MitRemoveCookie (
prev->next = auth->next;
else
mit_auth = auth->next;
- xfree (auth->data);
- xfree (auth);
+ free(auth->data);
+ free(auth);
return 1;
}
}
@@ -167,7 +167,7 @@ static char cookie[16]; /* 128 bits */
XID
MitGenerateCookie (
unsigned data_length,
- char *data,
+ const char *data,
XID id,
unsigned *data_length_return,
char **data_return)
diff --git a/xserver/os/osdep.h b/xserver/os/osdep.h
index 7b1c69995..3c0e78f06 100644
--- a/xserver/os/osdep.h
+++ b/xserver/os/osdep.h
@@ -114,7 +114,8 @@ SOFTWARE.
#if defined(XDMCP) || defined(HASXDMAUTH)
typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
-typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
+typedef Bool (*AddAuthorFunc)(unsigned name_length, const char *name,
+ unsigned data_length, char *data);
#endif
typedef struct _connectionInput {
@@ -124,6 +125,7 @@ typedef struct _connectionInput {
int bufcnt; /* count of bytes in buffer */
int lenLastReq;
int size;
+ unsigned int ignoreBytes; /* bytes to ignore before the next request */
} ConnectionInput, *ConnectionInputPtr;
typedef struct _connectionOutput {
@@ -138,19 +140,19 @@ struct _osComm;
#define AuthInitArgs void
typedef void (*AuthInitFunc) (AuthInitArgs);
-#define AuthAddCArgs unsigned short data_length, char *data, XID id
+#define AuthAddCArgs unsigned short data_length, const char *data, XID id
typedef int (*AuthAddCFunc) (AuthAddCArgs);
-#define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
+#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, char **reason
typedef XID (*AuthCheckFunc) (AuthCheckArgs);
#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
-#define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
+#define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
typedef XID (*AuthGenCFunc) (AuthGenCArgs);
-#define AuthRemCArgs unsigned short data_length, char *data
+#define AuthRemCArgs unsigned short data_length, const char *data
typedef int (*AuthRemCFunc) (AuthRemCArgs);
#define AuthRstCArgs void
@@ -254,29 +256,29 @@ extern void XdmcpUseMsg (void);
extern int XdmcpOptions(int argc, char **argv, int i);
extern void XdmcpRegisterConnection (
int type,
- char *address,
+ const char *address,
int addrlen);
extern void XdmcpRegisterAuthorizations (void);
-extern void XdmcpRegisterAuthorization (char *name, int namelen);
+extern void XdmcpRegisterAuthorization (const char *name, int namelen);
extern void XdmcpInit (void);
extern void XdmcpReset (void);
extern void XdmcpOpenDisplay(int sock);
extern void XdmcpCloseDisplay(int sock);
extern void XdmcpRegisterAuthentication (
- char *name,
+ const char *name,
int namelen,
- char *data,
+ const char *data,
int datalen,
ValidatorFunc Validator,
GeneratorFunc Generator,
AddAuthorFunc AddAuth);
struct sockaddr_in;
-extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
+extern void XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr);
#endif
#ifdef HASXDMAUTH
-extern void XdmAuthenticationInit (char *cookie, int cookie_length);
+extern void XdmAuthenticationInit (const char *cookie, int cookie_length);
#endif
#endif /* _OSDEP_H_ */
diff --git a/xserver/os/osinit.c b/xserver/os/osinit.c
index b85fa73b7..0da2cad45 100644
--- a/xserver/os/osinit.c
+++ b/xserver/os/osinit.c
@@ -161,7 +161,6 @@ void
OsInit(void)
{
static Bool been_here = FALSE;
- static char* admpath = ADMPATH;
static char* devnull = "/dev/null";
char fname[PATH_MAX];
@@ -229,8 +228,8 @@ OsInit(void)
{
FILE *err;
- if (strlen (display) + strlen (admpath) + 1 < sizeof fname)
- snprintf (fname, sizeof(fname), admpath, display);
+ if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
+ snprintf (fname, sizeof(fname), ADMPATH, display);
else
strlcpy (fname, devnull, sizeof(fname));
/*
diff --git a/xserver/os/privsep.c b/xserver/os/privsep.c
index 89fc4824a..cdbd8f6cf 100644
--- a/xserver/os/privsep.c
+++ b/xserver/os/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.14 2009/09/08 19:52:26 matthieu Exp $ */
+/* $OpenBSD: privsep.c,v 1.15 2010/12/05 15:36:10 matthieu Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -298,7 +298,6 @@ priv_init(uid_t uid, gid_t gid)
int
priv_open_device(const char *path)
{
- struct okdev *dev;
priv_cmd_t cmd;
if (priv_fd != -1) {
@@ -306,13 +305,8 @@ priv_open_device(const char *path)
strlcpy(cmd.arg.open.path, path, MAXPATHLEN);
write(priv_fd, &cmd, sizeof(cmd));
return receive_fd(priv_fd);
- } else if ((dev = open_ok(path)) != NULL) {
- return open(path, dev->flags);
- } else {
- errno = EPERM;
- return -1;
- }
- /* NOTREACHED */
+ } else
+ return open(path, O_RDWR | O_NONBLOCK | O_EXCL);
}
/* send signal to parent process */
diff --git a/xserver/os/rpcauth.c b/xserver/os/rpcauth.c
index 935d1b1d0..f0bd2f615 100644
--- a/xserver/os/rpcauth.c
+++ b/xserver/os/rpcauth.c
@@ -55,7 +55,7 @@ extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
static enum auth_stat why;
static char *
-authdes_ezdecode(char *inmsg, int len)
+authdes_ezdecode(const char *inmsg, int len)
{
struct rpc_msg msg;
char cred_area[MAX_AUTH_BYTES];
@@ -66,7 +66,7 @@ authdes_ezdecode(char *inmsg, int len)
XDR xdr;
SVCXPRT xprt;
- temp_inmsg = xalloc(len);
+ temp_inmsg = malloc(len);
memmove(temp_inmsg, inmsg, len);
memset((char *)&msg, 0, sizeof(msg));
@@ -79,7 +79,7 @@ authdes_ezdecode(char *inmsg, int len)
why = AUTH_FAILED;
xdrmem_create(&xdr, temp_inmsg, len, XDR_DECODE);
- if ((r.rq_clntcred = xalloc(MAX_AUTH_BYTES)) == NULL)
+ if ((r.rq_clntcred = malloc(MAX_AUTH_BYTES)) == NULL)
goto bad1;
r.rq_xprt = &xprt;
@@ -106,7 +106,7 @@ authdes_ezdecode(char *inmsg, int len)
return (((struct authdes_cred *) r.rq_clntcred)->adc_fullname.name);
bad2:
- xfree(r.rq_clntcred);
+ free(r.rq_clntcred);
bad1:
return ((char *)0); /* ((struct authdes_cred *) NULL); */
}
@@ -127,7 +127,7 @@ CheckNetName (
static char rpc_error[MAXNETNAMELEN+50];
_X_HIDDEN XID
-SecureRPCCheck (unsigned short data_length, char *data,
+SecureRPCCheck (unsigned short data_length, const char *data,
ClientPtr client, char **reason)
{
char *fullname;
@@ -160,7 +160,7 @@ SecureRPCInit (void)
}
_X_HIDDEN int
-SecureRPCAdd (unsigned short data_length, char *data, XID id)
+SecureRPCAdd (unsigned short data_length, const char *data, XID id)
{
if (data_length)
AddHost ((pointer) 0, FamilyNetname, data_length, data);
@@ -188,7 +188,7 @@ SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap)
}
_X_HIDDEN int
-SecureRPCRemove (unsigned short data_length, char *data)
+SecureRPCRemove (unsigned short data_length, const char *data)
{
return 0;
}
diff --git a/xserver/os/strcasecmp.c b/xserver/os/strcasecmp.c
index ca1051dc1..ad6da6a10 100644
--- a/xserver/os/strcasecmp.c
+++ b/xserver/os/strcasecmp.c
@@ -42,7 +42,7 @@ xstrcasecmp(const char *str1, const char *str2)
while (tolower(*us1) == tolower(*us2)) {
if (*us1++ == '\0')
- return (0);
+ return 0;
us2++;
}
diff --git a/xserver/os/strcasestr.c b/xserver/os/strcasestr.c
index b3d45495c..f89b2f2dc 100644
--- a/xserver/os/strcasestr.c
+++ b/xserver/os/strcasestr.c
@@ -54,7 +54,7 @@ xstrcasestr(const char *s, const char *find)
do {
do {
if ((sc = *s++) == 0)
- return (NULL);
+ return NULL;
} while ((char)tolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
s--;
diff --git a/xserver/os/strlcpy.c b/xserver/os/strlcpy.c
index aa9d042e0..e8e1b0217 100644
--- a/xserver/os/strlcpy.c
+++ b/xserver/os/strlcpy.c
@@ -50,5 +50,5 @@ strlcpy(char *dst, const char *src, size_t siz)
;
}
- return(s - src - 1); /* count does not include NUL */
+ return s - src - 1; /* count does not include NUL */
}
diff --git a/xserver/os/utils.c b/xserver/os/utils.c
index a635c0528..c1836ac84 100644
--- a/xserver/os/utils.c
+++ b/xserver/os/utils.c
@@ -120,9 +120,7 @@ __stdcall unsigned long GetTickCount(void);
#include "xkbsrv.h"
-#ifdef RENDER
#include "picture.h"
-#endif
Bool noTestExtensions;
#ifdef COMPOSITE
@@ -148,15 +146,10 @@ Bool noScreenSaverExtension = FALSE;
#ifdef MITSHM
Bool noMITShmExtension = FALSE;
#endif
-#ifdef MULTIBUFFER
-Bool noMultibufferExtension = FALSE;
-#endif
#ifdef RANDR
Bool noRRExtension = FALSE;
#endif
-#ifdef RENDER
Bool noRenderExtension = FALSE;
-#endif
#ifdef XCSECURITY
Bool noSecurityExtension = FALSE;
#endif
@@ -212,8 +205,6 @@ int auditTrailLevel = 1;
#define HAS_SAVED_IDS_AND_SETEUID
#endif
-static char *dev_tty_from_init = NULL; /* since we need to parse it anyway */
-
OsSigHandlerPtr
OsSignal(int sig, OsSigHandlerPtr handler)
{
@@ -535,9 +526,7 @@ void UseMsg(void)
ErrorF("-nopn reject failure to listen on all ports\n");
ErrorF("-r turns off auto-repeat\n");
ErrorF("r turns on auto-repeat \n");
-#ifdef RENDER
ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
-#endif
#ifndef __OpenBSD__
ErrorF("-retro start with classic stipple and cursor\n");
#else
@@ -579,12 +568,12 @@ void UseMsg(void)
static int
VerifyDisplayName(const char *d)
{
- if ( d == (char *)0 ) return( 0 ); /* null */
- if ( *d == '\0' ) return( 0 ); /* empty */
- if ( *d == '-' ) return( 0 ); /* could be confused for an option */
- if ( *d == '.' ) return( 0 ); /* must not equal "." or ".." */
- if ( strchr(d, '/') != (char *)0 ) return( 0 ); /* very important!!! */
- return( 1 );
+ if ( d == (char *)0 ) return 0; /* null */
+ if ( *d == '\0' ) return 0; /* empty */
+ if ( *d == '-' ) return 0; /* could be confused for an option */
+ if ( *d == '.' ) return 0; /* must not equal "." or ".." */
+ if ( strchr(d, '/') != (char *)0 ) return 0; /* very important!!! */
+ return 1;
}
/*
@@ -915,8 +904,7 @@ ProcessCommandLine(int argc, char *argv[])
}
else if (strncmp (argv[i], "tty", 3) == 0)
{
- /* just in case any body is interested */
- dev_tty_from_init = argv[i];
+ /* init supplies us with this useless information */
}
#ifdef XDMCP
else if ((skip = XdmcpOptions(argc, argv, i)) != i)
@@ -947,7 +935,6 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
-#ifdef RENDER
else if ( strcmp( argv[i], "-render" ) == 0)
{
if (++i < argc)
@@ -962,7 +949,6 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg ();
}
-#endif
else if ( strcmp( argv[i], "+extension") == 0)
{
if (++i < argc)
@@ -1017,7 +1003,7 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
gethostname(hname, 1024);
#if defined(IPv6) && defined(AF_INET6)
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
hnameptr = ai->ai_canonname;
@@ -1033,7 +1019,7 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
#endif
len = strlen(hnameptr) + 1;
- result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+ result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4);
p = result;
*p++ = sizeof(AUTHORIZATION_NAME) >> 8;
@@ -1062,150 +1048,99 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
void *
Xalloc(unsigned long amount)
{
- void *ptr;
+ /*
+ * Xalloc used to return NULL when large amount of memory is requested. In
+ * order to catch the buggy callers this warning has been added, slated to
+ * removal by anyone who touches this code (or just looks at it) in 2011.
+ *
+ * -- Mikhail Gusarov
+ */
+ if ((long)amount <= 0)
+ ErrorF("Warning: Xalloc: "
+ "requesting unpleasantly large amount of memory: %lu bytes.\n",
+ amount);
- if ((long)amount <= 0) {
- return NULL;
- }
- /* aligned extra on long word boundary */
- amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
- ptr = malloc(amount);
- return ptr;
+ return malloc(amount);
}
-/*****************
- * XNFalloc
- * "no failure" realloc
- *****************/
-
void *
XNFalloc(unsigned long amount)
{
- void *ptr;
-
- if ((long)amount <= 0)
- return NULL;
- /* aligned extra on long word boundary */
- amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
- ptr = malloc(amount);
+ void *ptr = malloc(amount);
if (!ptr)
FatalError("Out of memory");
return ptr;
}
-/*****************
- * Xcalloc
- *****************/
-
void *
Xcalloc(unsigned long amount)
{
- void *ret;
-
- ret = Xalloc (amount);
- if (ret)
- bzero (ret, (int) amount);
- return ret;
+ return calloc(1, amount);
}
-/*****************
- * XNFcalloc
- *****************/
-
void *
XNFcalloc(unsigned long amount)
{
- void *ret;
-
- ret = Xalloc (amount);
- if (ret)
- bzero (ret, (int) amount);
- else if ((long)amount > 0)
- FatalError("Out of memory");
+ void *ret = calloc(1, amount);
+ if (!ret)
+ FatalError("XNFcalloc: Out of memory");
return ret;
}
-/*****************
- * Xrealloc
- *****************/
-
void *
-Xrealloc(pointer ptr, unsigned long amount)
+Xrealloc(void *ptr, unsigned long amount)
{
+ /*
+ * Xrealloc used to return NULL when large amount of memory is requested. In
+ * order to catch the buggy callers this warning has been added, slated to
+ * removal by anyone who touches this code (or just looks at it) in 2011.
+ *
+ * -- Mikhail Gusarov
+ */
if ((long)amount <= 0)
- {
- if (ptr && !amount)
- free(ptr);
- return NULL;
- }
- amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
- if (ptr)
- ptr = realloc(ptr, amount);
- else
- ptr = malloc(amount);
+ ErrorF("Warning: Xrealloc: "
+ "requesting unpleasantly large amount of memory: %lu bytes.\n",
+ amount);
- return ptr;
+ return realloc(ptr, amount);
}
-
-/*****************
- * XNFrealloc
- * "no failure" realloc
- *****************/
void *
-XNFrealloc(pointer ptr, unsigned long amount)
+XNFrealloc(void *ptr, unsigned long amount)
{
- if ((ptr = Xrealloc(ptr, amount)) == NULL)
- {
- if ((long)amount > 0)
- FatalError( "Out of memory" );
- }
- return ptr;
+ void *ret = realloc(ptr, amount);
+ if (!ret)
+ FatalError("XNFrealloc: Out of memory");
+ return ret;
}
-/*****************
- * Xfree
- * calls free
- *****************/
-
void
-Xfree(pointer ptr)
+Xfree(void *ptr)
{
- if (ptr)
- free(ptr);
+ free(ptr);
}
char *
Xstrdup(const char *s)
{
- char *sd;
- size_t len;
-
if (s == NULL)
return NULL;
-
- len = strlen(s) + 1;
- sd = (char *)Xalloc(len);
- if (sd != NULL)
- strlcpy(sd, s, len);
- return sd;
+ return strdup(s);
}
-
char *
XNFstrdup(const char *s)
{
- char *sd;
- size_t len;
+ char *ret;
if (s == NULL)
return NULL;
-
- len = strlen(s) + 1;
- sd = (char *)XNFalloc(len);
- strlcpy(sd, s, len);
- return sd;
+
+ ret = strdup(s);
+ if (!ret)
+ FatalError("XNFstrdup: Out of memory");
+ return ret;
}
@@ -1267,7 +1202,7 @@ SmartScheduleInit (void)
if (SmartScheduleDisable)
return TRUE;
- bzero ((char *) &act, sizeof(struct sigaction));
+ memset((char *) &act, 0, sizeof(struct sigaction));
/* Set up the timer signal function */
act.sa_handler = SmartScheduleTimer;
@@ -1373,7 +1308,7 @@ System(char *command)
int status;
if (!command)
- return(1);
+ return 1;
#ifdef SIGCHLD
csig = signal(SIGCHLD, SIG_DFL);
@@ -1435,11 +1370,11 @@ Popen(char *command, char *type)
if ((*type != 'r' && *type != 'w') || type[1])
return NULL;
- if ((cur = xalloc(sizeof(struct pid))) == NULL)
+ if ((cur = malloc(sizeof(struct pid))) == NULL)
return NULL;
if (pipe(pdes) < 0) {
- xfree(cur);
+ free(cur);
return NULL;
}
@@ -1454,7 +1389,7 @@ Popen(char *command, char *type)
case -1: /* error */
close(pdes[0]);
close(pdes[1]);
- xfree(cur);
+ free(cur);
if (OsSignal(SIGALRM, old_alarm) == SIG_ERR)
perror("signal");
return NULL;
@@ -1521,11 +1456,11 @@ Fopen(char *file, char *type)
if ((*type != 'r' && *type != 'w') || type[1])
return NULL;
- if ((cur = xalloc(sizeof(struct pid))) == NULL)
+ if ((cur = malloc(sizeof(struct pid))) == NULL)
return NULL;
if (pipe(pdes) < 0) {
- xfree(cur);
+ free(cur);
return NULL;
}
@@ -1533,7 +1468,7 @@ Fopen(char *file, char *type)
case -1: /* error */
close(pdes[0]);
close(pdes[1]);
- xfree(cur);
+ free(cur);
return NULL;
case 0: /* child */
if (setgid(getgid()) == -1)
@@ -1627,7 +1562,7 @@ Pclose(pointer iop)
pidlist = cur->next;
else
last->next = cur->next;
- xfree(cur);
+ free(cur);
/* allow EINTR again */
OsReleaseSignals ();
@@ -1947,53 +1882,3 @@ error:
free(list);
return NULL;
}
-
-#ifdef __SCO__
-#include <fcntl.h>
-
-static void
-lockit (int fd, short what)
-{
- struct flock lck;
-
- lck.l_whence = 0;
- lck.l_start = 0;
- lck.l_len = 1;
- lck.l_type = what;
-
- (void)fcntl (fd, F_SETLKW, &lck);
-}
-
-/* SCO OpenServer 5 lacks pread/pwrite. Emulate them. */
-ssize_t
-pread (int fd, void *buf, size_t nbytes, off_t offset)
-{
- off_t saved;
- ssize_t ret;
-
- lockit (fd, F_RDLCK);
- saved = lseek (fd, 0, SEEK_CUR);
- lseek (fd, offset, SEEK_SET);
- ret = read (fd, buf, nbytes);
- lseek (fd, saved, SEEK_SET);
- lockit (fd, F_UNLCK);
-
- return ret;
-}
-
-ssize_t
-pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
-{
- off_t saved;
- ssize_t ret;
-
- lockit (fd, F_WRLCK);
- saved = lseek (fd, 0, SEEK_CUR);
- lseek (fd, offset, SEEK_SET);
- ret = write (fd, buf, nbytes);
- lseek (fd, saved, SEEK_SET);
- lockit (fd, F_UNLCK);
-
- return ret;
-}
-#endif /* __SCO__ */
diff --git a/xserver/os/xdmauth.c b/xserver/os/xdmauth.c
index e19e4f93d..b8cbada18 100644
--- a/xserver/os/xdmauth.c
+++ b/xserver/os/xdmauth.c
@@ -96,7 +96,7 @@ XdmAuthenticationGenerator (ARRAY8Ptr privateData, ARRAY8Ptr outgoingData,
}
static Bool
-XdmAuthenticationAddAuth (int name_len, char *name,
+XdmAuthenticationAddAuth (int name_len, const char *name,
int data_len, char *data)
{
Bool ret;
@@ -114,7 +114,7 @@ XdmAuthenticationAddAuth (int name_len, char *name,
'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
static int
-HexToBinary (char *in, char *out, int len)
+HexToBinary (const char *in, char *out, int len)
{
int top, bottom;
@@ -137,9 +137,9 @@ HexToBinary (char *in, char *out, int len)
}
void
-XdmAuthenticationInit (char *cookie, int cookie_len)
+XdmAuthenticationInit (const char *cookie, int cookie_len)
{
- bzero (privateKey.data, 8);
+ memset(privateKey.data, 0, 8);
if (!strncmp (cookie, "0x", 2) || !strncmp (cookie, "0X", 2))
{
if (cookie_len > 2 + 2 * 8)
@@ -188,7 +188,7 @@ static Bool gotClock;
#define TwentyFiveMinutes (25 * 60)
static Bool
-XdmClientAuthCompare (XdmClientAuthPtr a, XdmClientAuthPtr b)
+XdmClientAuthCompare (const XdmClientAuthPtr a, const XdmClientAuthPtr b)
{
int i;
@@ -201,7 +201,7 @@ XdmClientAuthCompare (XdmClientAuthPtr a, XdmClientAuthPtr b)
}
static void
-XdmClientAuthDecode (unsigned char *plain, XdmClientAuthPtr auth)
+XdmClientAuthDecode (const unsigned char *plain, XdmClientAuthPtr auth)
{
int i, j;
@@ -239,7 +239,7 @@ XdmClientAuthTimeout (long now)
prev->next = next;
else
xdmClients = next;
- xfree (client);
+ free(client);
}
else
prev = client;
@@ -259,20 +259,20 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
*reason = "Bad XDM authorization key length";
return NULL;
}
- client = xalloc (sizeof (XdmClientAuthRec));
+ client = malloc(sizeof (XdmClientAuthRec));
if (!client)
return NULL;
XdmClientAuthDecode (plain, client);
if (!XdmcpCompareKeys (&client->rho, rho))
{
- xfree (client);
+ free(client);
if (reason)
*reason = "Invalid XDM-AUTHORIZATION-1 key (failed key comparison)";
return NULL;
}
for (i = 18; i < 24; i++)
if (plain[i] != 0) {
- xfree (client);
+ free(client);
if (reason)
*reason = "Invalid XDM-AUTHORIZATION-1 key (failed NULL check)";
return NULL;
@@ -287,15 +287,15 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
#if defined(TCPCONN) || defined(STREAMSCONN)
if (family == FamilyInternet &&
memcmp((char *)addr, client->client, 4) != 0) {
- xfree (client);
- xfree (addr);
+ free(client);
+ free(addr);
if (reason)
*reason = "Invalid XDM-AUTHORIZATION-1 key (failed address comparison)";
return NULL;
}
#endif
- xfree (addr);
+ free(addr);
}
}
now = time(0);
@@ -308,7 +308,7 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
XdmClientAuthTimeout (now);
if (abs (client->time - now) > TwentyMinutes)
{
- xfree (client);
+ free(client);
if (reason)
*reason = "Excessive XDM-AUTHORIZATION-1 time offset";
return NULL;
@@ -317,7 +317,7 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
{
if (XdmClientAuthCompare (existing, client))
{
- xfree (client);
+ free(client);
if (reason)
*reason = "XDM authorization key matches an existing client!";
return NULL;
@@ -327,7 +327,7 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
}
int
-XdmAddCookie (unsigned short data_length, char *data, XID id)
+XdmAddCookie (unsigned short data_length, const char *data, XID id)
{
XdmAuthorizationPtr new;
unsigned char *rho_bits, *key_bits;
@@ -363,7 +363,7 @@ XdmAddCookie (unsigned short data_length, char *data, XID id)
/* the first octet of the key must be zero */
if (key_bits[0] != '\0')
return 0;
- new = xalloc (sizeof (XdmAuthorizationRec));
+ new = malloc(sizeof (XdmAuthorizationRec));
if (!new)
return 0;
new->next = xdmAuth;
@@ -375,7 +375,7 @@ XdmAddCookie (unsigned short data_length, char *data, XID id)
}
XID
-XdmCheckCookie (unsigned short cookie_length, char *cookie,
+XdmCheckCookie (unsigned short cookie_length, const char *cookie,
ClientPtr xclient, char **reason)
{
XdmAuthorizationPtr auth;
@@ -385,7 +385,7 @@ XdmCheckCookie (unsigned short cookie_length, char *cookie,
/* Auth packets must be a multiple of 8 bytes long */
if (cookie_length & 7)
return (XID) -1;
- plain = xalloc (cookie_length);
+ plain = malloc(cookie_length);
if (!plain)
return (XID) -1;
for (auth = xdmAuth; auth; auth=auth->next) {
@@ -394,11 +394,11 @@ XdmCheckCookie (unsigned short cookie_length, char *cookie,
{
client->next = xdmClients;
xdmClients = client;
- xfree (plain);
+ free(plain);
return auth->id;
}
}
- xfree (plain);
+ free(plain);
return (XID) -1;
}
@@ -411,13 +411,13 @@ XdmResetCookie (void)
for (auth = xdmAuth; auth; auth=next_auth)
{
next_auth = auth->next;
- xfree (auth);
+ free(auth);
}
xdmAuth = 0;
for (client = xdmClients; client; client=next_client)
{
next_client = client->next;
- xfree (client);
+ free(client);
}
xdmClients = (XdmClientAuthPtr) 0;
return 1;
@@ -430,21 +430,21 @@ XdmToID (unsigned short cookie_length, char *cookie)
XdmClientAuthPtr client;
unsigned char *plain;
- plain = xalloc (cookie_length);
+ plain = malloc(cookie_length);
if (!plain)
return (XID) -1;
for (auth = xdmAuth; auth; auth=auth->next) {
XdmcpUnwrap ((unsigned char *)cookie, (unsigned char *)&auth->key, plain, cookie_length);
if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, NULL, NULL)) != NULL)
{
- xfree (client);
- xfree (cookie);
- xfree (plain);
+ free(client);
+ free(cookie);
+ free(plain);
return auth->id;
}
}
- xfree (cookie);
- xfree (plain);
+ free(cookie);
+ free(plain);
return (XID) -1;
}
@@ -464,7 +464,7 @@ XdmFromID (XID id, unsigned short *data_lenp, char **datap)
}
int
-XdmRemoveCookie (unsigned short data_length, char *data)
+XdmRemoveCookie (unsigned short data_length, const char *data)
{
XdmAuthorizationPtr auth;
XdmAuthKeyPtr key_bits, rho_bits;
@@ -489,7 +489,7 @@ XdmRemoveCookie (unsigned short data_length, char *data)
XdmcpCompareKeys (key_bits, &auth->key))
{
xdmAuth = auth->next;
- xfree (auth);
+ free(auth);
return 1;
}
}
diff --git a/xserver/os/xdmcp.c b/xserver/os/xdmcp.c
index 1c6ec7888..546e5c05e 100644
--- a/xserver/os/xdmcp.c
+++ b/xserver/os/xdmcp.c
@@ -132,14 +132,14 @@ static struct multicastinfo {
#endif
static void XdmcpAddHost(
- struct sockaddr *from,
+ const struct sockaddr *from,
int fromlen,
ARRAY8Ptr AuthenticationName,
ARRAY8Ptr hostname,
ARRAY8Ptr status);
static void XdmcpSelectHost(
- struct sockaddr *host_sockaddr,
+ const struct sockaddr *host_sockaddr,
int host_len,
ARRAY8Ptr AuthenticationName);
@@ -169,10 +169,10 @@ static void send_keepalive_msg(void);
static void recv_alive_msg(unsigned /*length*/);
static void XdmcpFatal(
- char * /*type*/,
+ const char * /*type*/,
ARRAY8Ptr /*status*/);
-static void XdmcpWarning(char * /*str*/);
+static void XdmcpWarning(const char * /*str*/);
static void get_manager_by_name(
int /*argc*/,
@@ -210,7 +210,7 @@ static void XdmcpWakeupHandler(
static ARRAY8 ManufacturerDisplayID;
static void
-XdmcpRegisterManufacturerDisplayID (char *name, int length)
+XdmcpRegisterManufacturerDisplayID (const char *name, int length)
{
int i;
@@ -251,48 +251,48 @@ XdmcpOptions(int argc, char **argv, int i)
get_manager_by_name(argc, argv, i++);
XDM_INIT_STATE = XDM_QUERY;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-broadcast") == 0) {
XDM_INIT_STATE = XDM_BROADCAST;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
#if defined(IPv6) && defined(AF_INET6)
if (strcmp(argv[i], "-multicast") == 0) {
i = get_mcast_options(argc, argv, ++i);
XDM_INIT_STATE = XDM_MULTICAST;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-indirect") == 0) {
get_manager_by_name(argc, argv, i++);
XDM_INIT_STATE = XDM_INDIRECT;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-port") == 0) {
if (++i == argc) {
FatalError("Xserver: missing port number in command line\n");
}
xdm_udp_port = (unsigned short) atoi(argv[i]);
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-from") == 0) {
get_fromaddr_by_name(argc, argv, ++i);
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-once") == 0) {
OneSession = TRUE;
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-class") == 0) {
if (++i == argc) {
FatalError("Xserver: missing class name in command line\n");
}
defaultDisplayClass = argv[i];
- return (i + 1);
+ return i + 1;
}
#ifdef HASXDMAUTH
if (strcmp(argv[i], "-cookie") == 0) {
@@ -300,7 +300,7 @@ XdmcpOptions(int argc, char **argv, int i)
FatalError("Xserver: missing cookie data in command line\n");
}
xdmAuthCookie = argv[i];
- return (i + 1);
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-displayID") == 0) {
@@ -308,9 +308,9 @@ XdmcpOptions(int argc, char **argv, int i)
FatalError("Xserver: missing displayID in command line\n");
}
XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
- return (i + 1);
+ return i + 1;
}
- return (i);
+ return i;
}
/*
@@ -332,13 +332,13 @@ static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
static int NumBroadcastAddresses;
void
-XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr)
+XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr)
{
struct sockaddr_in *bcast;
if (NumBroadcastAddresses >= MAX_BROADCAST)
return;
bcast = &BroadcastAddresses[NumBroadcastAddresses++];
- bzero (bcast, sizeof (struct sockaddr_in));
+ memset(bcast, 0, sizeof (struct sockaddr_in));
#ifdef BSD44SOCKETS
bcast->sin_len = addr->sin_len;
#endif
@@ -364,9 +364,9 @@ static AuthenticationFuncsPtr AuthenticationFuncsList;
void
XdmcpRegisterAuthentication (
- char *name,
+ const char *name,
int namelen,
- char *data,
+ const char *data,
int datalen,
ValidatorFunc Validator,
GeneratorFunc Generator,
@@ -391,7 +391,7 @@ XdmcpRegisterAuthentication (
AuthenticationNames.length + 1) &&
XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
AuthenticationDatas.length + 1) &&
- (newFuncs = xalloc ((AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
+ (newFuncs = malloc((AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
{
XdmcpDisposeARRAY8 (&AuthenticationName);
XdmcpDisposeARRAY8 (&AuthenticationData);
@@ -402,7 +402,7 @@ XdmcpRegisterAuthentication (
newFuncs[AuthenticationNames.length-1].Validator = Validator;
newFuncs[AuthenticationNames.length-1].Generator = Generator;
newFuncs[AuthenticationNames.length-1].AddAuth = AddAuth;
- xfree (AuthenticationFuncsList);
+ free(AuthenticationFuncsList);
AuthenticationFuncsList = newFuncs;
AuthenticationNames.data[AuthenticationNames.length-1] = AuthenticationName;
AuthenticationDatas.data[AuthenticationDatas.length-1] = AuthenticationData;
@@ -420,7 +420,7 @@ static ARRAY8Ptr AuthenticationData = &noAuthenticationData;
static AuthenticationFuncsPtr AuthenticationFuncs;
static void
-XdmcpSetAuthentication (ARRAY8Ptr name)
+XdmcpSetAuthentication (const ARRAY8Ptr name)
{
int i;
@@ -445,7 +445,7 @@ static long xdmcpGeneration;
void
XdmcpRegisterConnection (
int type,
- char *address,
+ const char *address,
int addrlen)
{
int i;
@@ -492,18 +492,18 @@ XdmcpRegisterConnection (
}
if (ConnectionAddresses.length + 1 == 256)
return;
- newAddress = xalloc (addrlen * sizeof (CARD8));
+ newAddress = malloc(addrlen * sizeof (CARD8));
if (!newAddress)
return;
if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
{
- xfree (newAddress);
+ free(newAddress);
return;
}
if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
ConnectionAddresses.length + 1))
{
- xfree (newAddress);
+ free(newAddress);
return;
}
ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
@@ -528,17 +528,17 @@ XdmcpRegisterAuthorizations (void)
}
void
-XdmcpRegisterAuthorization (char *name, int namelen)
+XdmcpRegisterAuthorization (const char *name, int namelen)
{
ARRAY8 authName;
int i;
- authName.data = xalloc (namelen * sizeof (CARD8));
+ authName.data = malloc(namelen * sizeof (CARD8));
if (!authName.data)
return;
if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
{
- xfree (authName.data);
+ free(authName.data);
return;
}
for (i = 0; i < namelen; i++)
@@ -554,7 +554,7 @@ XdmcpRegisterAuthorization (char *name, int namelen)
static ARRAY8 DisplayClass;
static void
-XdmcpRegisterDisplayClass (char *name, int length)
+XdmcpRegisterDisplayClass (const char *name, int length)
{
int i;
@@ -728,7 +728,7 @@ XdmcpWakeupHandler(
static void
XdmcpSelectHost(
- struct sockaddr *host_sockaddr,
+ const struct sockaddr *host_sockaddr,
int host_len,
ARRAY8Ptr AuthenticationName)
{
@@ -748,7 +748,7 @@ XdmcpSelectHost(
/*ARGSUSED*/
static void
XdmcpAddHost(
- struct sockaddr *from,
+ const struct sockaddr *from,
int fromlen,
ARRAY8Ptr AuthenticationName,
ARRAY8Ptr hostname,
@@ -854,7 +854,7 @@ send_packet(void)
*/
static void
-XdmcpDeadSession (char *reason)
+XdmcpDeadSession (const char *reason)
{
ErrorF ("XDM: %s, declaring session dead\n", reason);
state = XDM_INIT_STATE;
@@ -1448,7 +1448,7 @@ recv_alive_msg (unsigned length)
static void
XdmcpFatal (
- char *type,
+ const char *type,
ARRAY8Ptr status)
{
FatalError ("XDMCP fatal error: %s %*.*s\n", type,
@@ -1456,15 +1456,15 @@ XdmcpFatal (
}
static void
-XdmcpWarning(char *str)
+XdmcpWarning(const char *str)
{
ErrorF("XDMCP warning: %s\n", str);
}
static void
get_addr_by_name(
- char * argtype,
- char * namestr,
+ const char *argtype,
+ const char *namestr,
int port,
int socktype,
SOCKADDR_TYPE *addr,
@@ -1483,7 +1483,7 @@ get_addr_by_name(
char *pport = portstr;
int gaierr;
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_socktype = socktype;
if (port == 0) {
@@ -1616,7 +1616,7 @@ get_mcast_options(int argc, char **argv, int i)
} else {
FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
}
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM;
if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
diff --git a/xserver/os/xprintf.c b/xserver/os/xprintf.c
index 07eaa1f58..71a4424f7 100644
--- a/xserver/os/xprintf.c
+++ b/xserver/os/xprintf.c
@@ -54,7 +54,7 @@ Xvprintf(const char *format, va_list va)
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
- ret = (char *)Xalloc(size + 1);
+ ret = (char *)malloc(size + 1);
if (ret == NULL)
return NULL;
@@ -84,7 +84,7 @@ XNFvprintf(const char *format, va_list va)
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
- ret = (char *)XNFalloc(size + 1);
+ ret = (char *)xnfalloc(size + 1);
if (ret == NULL)
return NULL;
diff --git a/xserver/os/xsha1.c b/xserver/os/xsha1.c
index 355862fb1..5ea71da46 100644
--- a/xserver/os/xsha1.c
+++ b/xserver/os/xsha1.c
@@ -12,7 +12,7 @@
void *x_sha1_init(void)
{
- SHA1_CTX *ctx = xalloc(sizeof(*ctx));
+ SHA1_CTX *ctx = malloc(sizeof(*ctx));
if (!ctx)
return NULL;
SHA1Init(ctx);
@@ -30,7 +30,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
{
SHA1_CTX *sha1_ctx = ctx;
SHA1Final(result, sha1_ctx);
- xfree(sha1_ctx);
+ free(sha1_ctx);
return 1;
}
@@ -40,7 +40,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
void *x_sha1_init(void)
{
- CC_SHA1_CTX *ctx = xalloc(sizeof(*ctx));
+ CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
if (!ctx)
return NULL;
CC_SHA1_Init(ctx);
@@ -58,7 +58,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
{
CC_SHA1_CTX *sha1_ctx = ctx;
CC_SHA1_Final(result, sha1_ctx);
- xfree(sha1_ctx);
+ free(sha1_ctx);
return 1;
}
@@ -107,7 +107,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
void *x_sha1_init(void)
{
- sha1_ctx *ctx = xalloc(sizeof(*ctx));
+ sha1_ctx *ctx = malloc(sizeof(*ctx));
if(!ctx)
return NULL;
sha1_begin(ctx);
@@ -123,7 +123,7 @@ int x_sha1_update(void *ctx, void *data, int size)
int x_sha1_final(void *ctx, unsigned char result[20])
{
sha1_end(result, ctx);
- xfree(ctx);
+ free(ctx);
return 1;
}
@@ -135,12 +135,12 @@ int x_sha1_final(void *ctx, unsigned char result[20])
void *x_sha1_init(void)
{
int ret;
- SHA_CTX *ctx = xalloc(sizeof(*ctx));
+ SHA_CTX *ctx = malloc(sizeof(*ctx));
if (!ctx)
return NULL;
ret = SHA1_Init(ctx);
if (!ret) {
- xfree(ctx);
+ free(ctx);
return NULL;
}
return ctx;
@@ -152,7 +152,7 @@ int x_sha1_update(void *ctx, void *data, int size)
SHA_CTX *sha_ctx = ctx;
ret = SHA1_Update(sha_ctx, data, size);
if (!ret)
- xfree(sha_ctx);
+ free(sha_ctx);
return ret;
}
@@ -161,7 +161,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
int ret;
SHA_CTX *sha_ctx = ctx;
ret = SHA1_Final(result, sha_ctx);
- xfree(sha_ctx);
+ free(sha_ctx);
return ret;
}