libice: Changes to 'upstream-unstable'
.gitignore | 1 +
Makefile.am | 5 +++++
configure.ac | 7 ++++++-
src/Makefile.am | 8 ++++++++
src/accept.c | 5 +----
src/authutil.c | 51 +++++++++++++--------------------------------------
src/connect.c | 13 ++++---------
src/getauth.c | 11 ++++-------
src/iceauth.c | 33 ++++++++++++---------------------
src/listen.c | 11 +++--------
src/listenwk.c | 2 ++
src/misc.c | 22 +++-------------------
src/process.c | 26 +++++++++++---------------
src/register.c | 30 ++++++++----------------------
src/setauth.c | 22 ++++++++--------------
15 files changed, 89 insertions(+), 158 deletions(-)
New commits:
commit f415da71dd26f128df7d550ecd7631f8888eb1d2
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Aug 20 13:21:07 2007 -0700
Version bump: 1.0.4
diff --git a/configure.ac b/configure.ac
index 2cea81f..918e129 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
AC_PREREQ(2.57)
AC_INIT([libICE],
- 1.0.3,
+ 1.0.4,
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
libICE)
commit 8e08d3e4b8f00151b3a8b7eb88015dc15170e154
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Jun 4 15:40:22 2007 -0700
Add $(AM_CFLAGS) to lint flags to get correct Xtrans flags
diff --git a/src/Makefile.am b/src/Makefile.am
index 0207a89..449aeaf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,7 +41,7 @@ iceinclude_HEADERS=\
if LINT
ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS)
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
lint:
$(LINT) $(ALL_LINT_FLAGS) $(libICE_la_SOURCES) $(XINERAMA_LIBS)
commit cd900e40b5676874d076c35466fd7baa6a49b1f6
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 15:05:52 2007 -0700
Replace many malloc(strlen()); strcpy() pairs with strdup()
diff --git a/src/accept.c b/src/accept.c
index df2b258..d54ffd4 100644
--- a/src/accept.c
+++ b/src/accept.c
@@ -92,8 +92,7 @@ IceAcceptStatus *statusRet;
iceConn->send_sequence = 0;
iceConn->receive_sequence = 0;
- iceConn->connection_string = (char *) malloc (
- strlen (listenObj->network_id) + 1);
+ iceConn->connection_string = strdup(listenObj->network_id);
if (iceConn->connection_string == NULL)
{
@@ -102,8 +101,6 @@ IceAcceptStatus *statusRet;
*statusRet = IceAcceptBadMalloc;
return (NULL);
}
- else
- strcpy (iceConn->connection_string, listenObj->network_id);
iceConn->vendor = NULL;
iceConn->release = NULL;
diff --git a/src/connect.c b/src/connect.c
index 933c186..3874058 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -524,9 +524,7 @@ ConnectToPeer (char *networkIdsList, char **actualConnectionRet)
* We need to return the actual network connection string
*/
- *actualConnectionRet = (char *) malloc (strlen (address) + 1);
- strcpy (*actualConnectionRet, address);
-
+ *actualConnectionRet = strdup(address);
/*
* Return the file descriptor
diff --git a/src/iceauth.c b/src/iceauth.c
index 38500a5..dcee7ed 100644
--- a/src/iceauth.c
+++ b/src/iceauth.c
@@ -135,12 +135,10 @@ char **errorStringRet;
if (!data)
{
- char *tempstr =
+ const char *tempstr =
"Could not find correct MIT-MAGIC-COOKIE-1 authentication";
- *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
- if (*errorStringRet)
- strcpy (*errorStringRet, tempstr);
+ *errorStringRet = strdup(tempstr);
return (IcePoAuthFailed);
}
@@ -161,11 +159,10 @@ char **errorStringRet;
* a single pass authentication method.
*/
- char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error";
+ const char *tempstr =
+ "MIT-MAGIC-COOKIE-1 authentication internal error";
- *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
- if (*errorStringRet)
- strcpy (*errorStringRet, tempstr);
+ *errorStringRet = strdup(tempstr);
return (IcePoAuthFailed);
}
@@ -226,11 +223,10 @@ char **errorStringRet;
}
else
{
- char *tempstr = "MIT-MAGIC-COOKIE-1 authentication rejected";
+ const char *tempstr
+ = "MIT-MAGIC-COOKIE-1 authentication rejected";
- *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
- if (*errorStringRet)
- strcpy (*errorStringRet, tempstr);
+ *errorStringRet = strdup(tempstr);
stat = IcePaAuthRejected;
}
@@ -246,12 +242,10 @@ char **errorStringRet;
* always find a valid entry.
*/
- char *tempstr =
+ const char *tempstr =
"MIT-MAGIC-COOKIE-1 authentication internal error";
- *errorStringRet = (char *) malloc (strlen (tempstr) + 1);
- if (*errorStringRet)
- strcpy (*errorStringRet, tempstr);
+ *errorStringRet = strdup(tempstr);
return (IcePaAuthFailed);
}
diff --git a/src/listen.c b/src/listen.c
index 9875f30..d3aa4b2 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -177,14 +177,7 @@ IceGetListenConnectionString (listenObj)
IceListenObj listenObj;
{
- char *networkId;
-
- networkId = (char *) malloc (strlen (listenObj->network_id) + 1);
-
- if (networkId)
- strcpy (networkId, listenObj->network_id);
-
- return (networkId);
+ return strdup(listenObj->network_id);
}
diff --git a/src/misc.c b/src/misc.c
index 45c1f7e..304ae60 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -129,12 +129,7 @@ IceVendor (iceConn)
IceConn iceConn;
{
- char *string = (char *) malloc (strlen (iceConn->vendor) + 1);
-
- if (string)
- strcpy (string, iceConn->vendor);
-
- return (string);
+ return strdup(iceConn->vendor);
}
@@ -144,12 +139,7 @@ IceRelease (iceConn)
IceConn iceConn;
{
- char *string = (char *) malloc (strlen (iceConn->release) + 1);
-
- if (string)
- strcpy (string, iceConn->release);
-
- return (string);
+ return strdup(iceConn->release);
}
@@ -191,13 +181,7 @@ IceConn iceConn;
{
if (iceConn->connection_string)
{
- char *string = (char *) malloc (
- strlen (iceConn->connection_string) + 1);
-
- if (string)
- strcpy (string, iceConn->connection_string);
-
- return (string);
+ return strdup(iceConn->connection_string);
}
else
return (NULL);
diff --git a/src/process.c b/src/process.c
index 2a97dcb..416f1c6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -615,7 +615,7 @@ IceReplyWaitInfo *replyWait;
_IceConnectionError *errorReply =
&(((_IceReply *) (replyWait->reply))->connection_error);
char *errorStr = NULL;
- char *tempstr;
+ const char *tempstr;
char *prefix, *temp;
invokeHandler = 0;
@@ -627,16 +627,14 @@ IceReplyWaitInfo *replyWait;
tempstr =
"None of the ICE versions specified are supported";
- errorStr = (char *) malloc (strlen (tempstr) + 1);
- strcpy (errorStr, tempstr);
+ errorStr = strdup(tempstr);
break;
case IceNoAuth:
tempstr =
"None of the authentication protocols specified are supported";
- errorStr = (char *) malloc (strlen (tempstr) + 1);
- strcpy (errorStr, tempstr);
+ errorStr = strdup(tempstr);
break;
case IceSetupFailed:
@@ -697,16 +695,14 @@ IceReplyWaitInfo *replyWait;
temp =
"None of the protocol versions specified are supported";
- errorStr = (char *) malloc (strlen (temp) + 1);
- strcpy (errorStr, temp);
+ errorStr = strdup(temp);
break;
case IceNoAuth:
temp =
"None of the authentication protocols specified are supported";
- errorStr = (char *) malloc (strlen (temp) + 1);
- strcpy (errorStr, temp);
+ errorStr = strdup(temp);
break;
case IceSetupFailed:
@@ -1129,11 +1125,11 @@ IceReplyWaitInfo *replyWait;
_IceConnectionError *errorReply =
&(((_IceReply *) (replyWait->reply))->connection_error);
- char *tempstr = "Received bad authIndex in the AuthRequired message";
+ const char *tempstr
+ = "Received bad authIndex in the AuthRequired message";
char errIndex = (int) message->authIndex;
- errorString = (char *) malloc (strlen (tempstr) + 1);
- strcpy (errorString, tempstr);
+ errorString = strdup(tempstr);
errorReply->type = ICE_CONNECTION_ERROR;
errorReply->error_message = errorString;
@@ -1159,11 +1155,11 @@ IceReplyWaitInfo *replyWait;
_IceProtocolError *errorReply =
&(((_IceReply *) (replyWait->reply))->protocol_error);
- char *tempstr = "Received bad authIndex in the AuthRequired message";
+ const char *tempstr
+ = "Received bad authIndex in the AuthRequired message";
char errIndex = (int) message->authIndex;
- errorString = (char *) malloc (strlen (tempstr) + 1);
- strcpy (errorString, tempstr);
+ errorString = strdup(tempstr);
errorReply->type = ICE_PROTOCOL_ERROR;
errorReply->error_message = errorString;
diff --git a/src/register.c b/src/register.c
index 20e60df..bcf95a2 100644
--- a/src/register.c
+++ b/src/register.c
@@ -85,8 +85,7 @@ IceIOErrorProc IOErrorProc;
char *name;
_IceProtocols[_IceLastMajorOpcode].protocol_name = name =
- (char *) malloc (strlen (protocolName) + 1);
- strcpy (name, protocolName);
+ strdup(protocolName);
p = _IceProtocols[_IceLastMajorOpcode].orig_client =
(_IcePoProtocol *) malloc (sizeof (_IcePoProtocol));
@@ -96,11 +95,8 @@ IceIOErrorProc IOErrorProc;
opcodeRet = ++_IceLastMajorOpcode;
}
- p->vendor = (char *) malloc (strlen (vendor) + 1);
- strcpy (p->vendor, vendor);
-
- p->release = (char *) malloc (strlen (release) + 1);
- strcpy (p->release, release);
+ p->vendor = strdup(vendor);
+ p->release = strdup(release);
p->version_count = versionCount;
@@ -119,10 +115,7 @@ IceIOErrorProc IOErrorProc;
for (i = 0; i < authCount; i++)
{
- p->auth_names[i] =
- (char *) malloc (strlen (authNames[i]) + 1);
- strcpy (p->auth_names[i], authNames[i]);
-
+ p->auth_names[i] = strdup(authNames[i]);
p->auth_procs[i] = authProcs[i];
}
}
@@ -197,8 +190,7 @@ IceIOErrorProc IOErrorProc;
char *name;
_IceProtocols[_IceLastMajorOpcode].protocol_name = name =
- (char *) malloc (strlen (protocolName) + 1);
- strcpy (name, protocolName);
+ strdup(protocolName);
_IceProtocols[_IceLastMajorOpcode].orig_client = NULL;
@@ -208,11 +200,8 @@ IceIOErrorProc IOErrorProc;
opcodeRet = ++_IceLastMajorOpcode;
}
- p->vendor = (char *) malloc (strlen (vendor) + 1);
- strcpy (p->vendor, vendor);
-
- p->release = (char *) malloc (strlen (release) + 1);
- strcpy (p->release, release);
+ p->vendor = strdup(vendor);
+ p->release = strdup(release);
p->version_count = versionCount;
@@ -234,10 +223,7 @@ IceIOErrorProc IOErrorProc;
for (i = 0; i < authCount; i++)
{
- p->auth_names[i] =
- (char *) malloc (strlen (authNames[i]) + 1);
- strcpy (p->auth_names[i], authNames[i]);
-
+ p->auth_names[i] = strdup(authNames[i]);
p->auth_procs[i] = authProcs[i];
}
}
diff --git a/src/setauth.c b/src/setauth.c
index 4fd7718..8ed9cef 100644
--- a/src/setauth.c
+++ b/src/setauth.c
@@ -96,20 +96,14 @@ IceAuthDataEntry *entries;
_IcePaAuthDataEntryCount++;
}
- _IcePaAuthDataEntries[j].protocol_name = (char *) malloc (
- strlen (entries[i].protocol_name) + 1);
- strcpy (_IcePaAuthDataEntries[j].protocol_name,
- entries[i].protocol_name);
-
- _IcePaAuthDataEntries[j].network_id = (char *) malloc (
- strlen (entries[i].network_id) + 1);
- strcpy (_IcePaAuthDataEntries[j].network_id,
- entries[i].network_id);
-
- _IcePaAuthDataEntries[j].auth_name = (char *) malloc (
- strlen (entries[i].auth_name) + 1);
- strcpy (_IcePaAuthDataEntries[j].auth_name,
- entries[i].auth_name);
+ _IcePaAuthDataEntries[j].protocol_name
+ = strdup(entries[i].protocol_name);
+
+ _IcePaAuthDataEntries[j].network_id
+ = strdup(entries[i].network_id);
+
+ _IcePaAuthDataEntries[j].auth_name
+ = strdup(entries[i].auth_name);
_IcePaAuthDataEntries[j].auth_data_length =
entries[i].auth_data_length;
commit 27f9a9324d58c9a7472c724c62f5b7ea0e1f4681
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:43:05 2007 -0700
Provide ANSI C prototypes for more static functions
diff --git a/src/connect.c b/src/connect.c
index e06aa04..933c186 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -36,7 +36,8 @@ Author: Ralph Mor, X Consortium
#include <X11/Xtrans/Xtrans.h>
#include "globals.h"
-static XtransConnInfo ConnectToPeer();
+static XtransConnInfo ConnectToPeer(char *networkIdsList,
+ char **actualConnectionRet);
#define Strstr strstr
@@ -449,11 +450,7 @@ IceConn iceConn;
static XtransConnInfo
-ConnectToPeer (networkIdsList, actualConnectionRet)
-
-char *networkIdsList;
-char **actualConnectionRet;
-
+ConnectToPeer (char *networkIdsList, char **actualConnectionRet)
{
char addrbuf[256];
char* address;
diff --git a/src/getauth.c b/src/getauth.c
index 73fcd8a..4ad7878 100644
--- a/src/getauth.c
+++ b/src/getauth.c
@@ -35,7 +35,8 @@ Author: Ralph Mor, X Consortium
#include "ICElibint.h"
#include <X11/ICE/ICEutil.h>
-static Bool auth_valid ();
+static Bool auth_valid (const char *auth_name, int num_auth_names,
+ char **auth_names, int *index_ret);
extern int _IcePaAuthDataEntryCount;
extern IceAuthDataEntry _IcePaAuthDataEntries[];
@@ -244,12 +245,8 @@ int *indices_ret; /* in/out arg */
*/
static Bool
-auth_valid (auth_name, num_auth_names, auth_names, index_ret)
-
-char *auth_name;
-int num_auth_names;
-char **auth_names;
-int *index_ret;
+auth_valid (const char *auth_name, int num_auth_names,
+ char **auth_names, int *index_ret)
{
/*
diff --git a/src/iceauth.c b/src/iceauth.c
index 01c73ce..38500a5 100644
--- a/src/iceauth.c
+++ b/src/iceauth.c
@@ -38,7 +38,7 @@ Author: Ralph Mor, X Consortium
#include <time.h>
#define Time_t time_t
-static int binaryEqual ();
+static int binaryEqual (const char *a, const char *b, unsigned len);
static int was_called_state;
@@ -265,10 +265,7 @@ char **errorStringRet;
*/
static int
-binaryEqual (a, b, len)
-
-register char *a, *b;
-register unsigned len;
+binaryEqual (const char *a, const char *b, unsigned len)
{
while (len--)
commit bb639803a779ceace05d183b653da88f010ab29c
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:32:31 2007 -0700
Convert authutil.c static helpers to ANSI C prototypes to clear sparse warnings
diff --git a/src/authutil.c b/src/authutil.c
index 1cc58d8..c1d1aee 100644
--- a/src/authutil.c
+++ b/src/authutil.c
@@ -55,12 +55,12 @@ extern unsigned sleep ();
#endif
#endif
-static Status read_short ();
-static Status read_string ();
-static Status read_counted_string ();
-static Status write_short ();
-static Status write_string ();
-static Status write_counted_string ();
+static Status read_short (FILE *file, unsigned short *shortp);
+static Status read_string (FILE *file, char **stringp);
+static Status read_counted_string (FILE *file, unsigned short *countp, char **stringp);
+static Status write_short (FILE *file, unsigned short s);
+static Status write_string (FILE *file, char *string);
+static Status write_counted_string (FILE *file, unsigned short count, char *string);
@@ -71,7 +71,7 @@ static Status write_counted_string ();
*/
char *
-IceAuthFileName ()
+IceAuthFileName (void)
{
static char slashDotICEauthority[] = "/.ICEauthority";
@@ -393,11 +393,7 @@ char *auth_name;
*/
static Status
-read_short (file, shortp)
-
-FILE *file;
-unsigned short *shortp;
-
+read_short (FILE *file, unsigned short *shortp)
{
unsigned char file_short[2];
@@ -410,10 +406,7 @@ unsigned short *shortp;
static Status
-read_string (file, stringp)
-
-FILE *file;
-char **stringp;
+read_string (FILE *file, char **stringp)
{
unsigned short len;
@@ -445,12 +438,7 @@ char **stringp;
static Status
-read_counted_string (file, countp, stringp)
-
-FILE *file;
-unsigned short *countp;
-char **stringp;
-
+read_counted_string (FILE *file, unsigned short *countp, char **stringp)
{
unsigned short len;
char *data;
@@ -484,11 +472,7 @@ char **stringp;
static Status
-write_short (file, s)
-
-FILE *file;
-unsigned short s;
-
+write_short (FILE *file, unsigned short s)
{
unsigned char file_short[2];
@@ -503,11 +487,7 @@ unsigned short s;
static Status
-write_string (file, string)
-
-FILE *file;
-char *string;
-
+write_string (FILE *file, char *string)
{
unsigned short count = strlen (string);
@@ -522,12 +502,7 @@ char *string;
static Status
-write_counted_string (file, count, string)
-
-FILE *file;
-unsigned short count;
-char *string;
-
+write_counted_string (FILE *file, unsigned short count, char *string)
{
if (!write_short (file, count))
return (0);
commit 2179b2d467d69e45559b8e4f161a904a21f05321
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:28:06 2007 -0700
Add hooks for checking source code with lint/sparse/etc.
diff --git a/Makefile.am b/Makefile.am
index d3dd678..2d72364 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,3 +10,8 @@ ChangeLog:
(GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
dist-hook: ChangeLog
+
+if LINT
+lint:
+ (cd src && $(MAKE) $(MFLAGS) lint)
+endif LINT
diff --git a/configure.ac b/configure.ac
index fb79a19..2cea81f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,11 @@ AC_DEFINE(ICE_t, 1, [Xtrans transport type])
# Checks for header files.
AC_HEADER_STDC
+dnl Allow checking code with lint, sparse, etc.
+XORG_WITH_LINT
+XORG_LINT_LIBRARY([ICE])
+LINT_FLAGS="${LINT_FLAGS} ${ICE_CFLAGS} ${XTRANS_CFLAGS}"
+
if test "x$GCC" = "xyes"; then
GCC_WARNINGS="-Wall -Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
diff --git a/src/Makefile.am b/src/Makefile.am
index b549ede..0207a89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,3 +38,11 @@ iceinclude_HEADERS=\
$(top_srcdir)/include/X11/ICE/ICEmsg.h \
$(top_srcdir)/include/X11/ICE/ICEproto.h \
$(top_srcdir)/include/X11/ICE/ICEutil.h
+
+if LINT
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) $(libICE_la_SOURCES) $(XINERAMA_LIBS)
+endif LINT
commit 6b361c028b5ad931b61df86fae570f3ef9f41c15
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:19:56 2007 -0700
Coverity #1086: Double free of pointer "*listenObjsRet"
Same bug, different function.
diff --git a/src/listenwk.c b/src/listenwk.c
index f97aa44..26bb6e0 100644
--- a/src/listenwk.c
+++ b/src/listenwk.c
@@ -127,8 +127,10 @@ char *errorStringRet;
free ((char *) (*listenObjsRet)[j]);
free ((char *) *listenObjsRet);
+ *listenObjsRet = NULL;
status = 0;
+ break;
}
else
{
commit c9b3d016681d81aff32c74cdad75151bd538e6ab
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:07:42 2007 -0700
Coverity #1085: Double free of pointer "*listenObjsRet"
If malloc failed in the loop in IceListenForConnections, the error path
would free all previous allocations, then loop around and try again, and
if it failed again, free the previous allocations again. On the other
hand, if it succeeded on the later tries, then the memory would just be
leaked, since the error would be returned and not the pointer to them.
diff --git a/src/listen.c b/src/listen.c
index 7708cfe..9875f30 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -123,8 +123,10 @@ char *errorStringRet;
free ((char *) (*listenObjsRet)[j]);
free ((char *) *listenObjsRet);
+ *listenObjsRet = NULL;
status = 0;
+ break;
}
else
{
commit 6039e865470af23948b0fe7d5dc0ea72da436b0e
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Apr 5 14:04:01 2007 -0700
Add *~ to .gitignore to skip emacs/patch droppings
diff --git a/.gitignore b/.gitignore
index c33111a..da4d9c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@ MakeOut
missing
mkinstalldirs
stamp-h1
+*~
Reply to: