iceauh 1.0.2

This commit is contained in:
matthieu
2007-09-11 11:19:35 +00:00
parent 006a456e77
commit 3960c21118
8 changed files with 505 additions and 253 deletions

View File

@@ -1,30 +1,277 @@
2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
commit 5e52eb5d27986490dfad02781a452b8d0650f4b9
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Jul 23 18:23:56 2007 -0700
* configure.ac:
Update package version for X11R7 release.
Version bump: 1.0.2
2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org>
commit 4471761150676a8cee5631615bc187019b760161
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Jul 23 17:49:59 2007 -0700
* configure.ac:
Update package version number for final X11R7 release candidate.
Change iceauth_CFLAGS to AM_CFLAGS to avoid automake-1.10 warning
Makefile.am:27: compiling `iceauth.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org>
commit bc7a27ab2e4e3339b9c2ee3bb90a38662b128448
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Fri May 18 12:58:23 2007 -0700
* Makefile.am:
Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
More constification and reduction of rw data in binary
2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org>
commit 45bb32cecdcf3319ae268f29a3ba1c33378e0acf
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Fri May 18 12:57:00 2007 -0700
* configure.ac:
Update package version number for X11R7 RC3 release.
Debian Bug #25285: iceauth manpage starts with blank screen
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=25285>
2005-11-20 Alan Coopersmith <alan.coopersmith@sun.com>
commit bff96f0f863ba98fe5a66110ae0e29ca26336861
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu May 17 14:08:03 2007 -0700
* configure.ac:
iceauth only depends on xproto headers, not x11 library
Constify some static data constants
2005-10-18 Kevin E. Martin <kem-at-freedesktop-dot-org>
commit c5e43b03ca7176907dd8d0d0964e0fd0460b9ff5
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu May 17 13:50:05 2007 -0700
* configure.ac:
Update package version number for RC1 release.
ANSIfy function declarations
commit b2761be7f786fe9fde424b4331479d3ac5082f16
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu May 17 13:23:25 2007 -0700
Fix some lint warnings
(611) warning: assignment of 64-bit integer to 32-bit integer
(653) warning: variable argument to strcpy(); make sure it's safe
(728) warning: sign extension from 32-bit to 64-bit integer
commit 77cadcef6ea687e7181aa222c47402f34644a6ea
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu May 17 13:02:49 2007 -0700
Add option to check code with lint/sparse/etc.
commit 2afbb4393b1053fcb2edbec7c92575245efabffe
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu May 17 12:59:51 2007 -0700
Replace static ChangeLog with disthook to generate from git log
commit 0022cf7baf11bccea0024d0dc8c1ecc37e46ef3d
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Wed May 16 20:14:10 2007 -0700
Bug 10739: iceauth dumps core if signal caught before initialization done
X.Org Bugzilla #10739 <http://bugs.freedesktop.org/show_bug.cgi?id=10739>
Adding a test for NULL filename before calling IceUnlockAuthFile in
auth_finalize cleared the crash, but left the lock file behind.
Moving the initialization of authfilename to earlier in auth_initialize()
allowed the locks to be cleaned up as well.
commit f749d926bd9796badee2efd1ee1da5905d6fd38d
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon May 14 19:04:24 2007 -0700
Replace copystring() with strdup() calls
Also solves Coverity #924: Function copystring:
Pointer "src" dereferenced before NULL check
commit 1a142e8b29113bbd9daf21b8371f1572cd0152dd
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon May 14 18:57:31 2007 -0700
Coverity #1089: Double frees in error cleanup path
Double free of pointer "(auth)->auth_data" in call to "free"
Double free of pointer "(auth)->protocol_data" in call to "free"
commit 4c1bd3d698bbb2ec4c1f8d3744549ec44c58d1bf
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon May 14 18:47:48 2007 -0700
renamed: .cvsignore -> .gitignore
commit ca8a9af2c282da78eac601e316d7db553cb411b3
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon May 14 18:47:24 2007 -0700
Coverity #1039: Using uninitialized value "authdata"
commit 59ccc789fa5d7d34cd81d28f46b6022e92536d6b
Author: Kevin E Martin <kem@kem.org>
Date: Wed Dec 21 02:29:42 2005 +0000
Update package version for X11R7 release.
commit d8dd7304386ba1ca8a6fbbcdcc6c4d790599ac91
Author: Adam Jackson <ajax@nwnk.net>
Date: Mon Dec 19 16:22:40 2005 +0000
Stub COPYING files
commit f3a5ff191dda517c3331760d97549a826ede4266
Author: Kevin E Martin <kem@kem.org>
Date: Thu Dec 15 00:24:02 2005 +0000
Update package version number for final X11R7 release candidate.
commit 589df4ac932d1c5616c12a331ef99c0ac6f75563
Author: Kevin E Martin <kem@kem.org>
Date: Tue Dec 6 22:48:16 2005 +0000
Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
commit 7ec4ba15177f055afb6dc9972763c25bfc79cec9
Author: Kevin E Martin <kem@kem.org>
Date: Sat Dec 3 05:49:15 2005 +0000
Update package version number for X11R7 RC3 release.
commit 31a2c7a834076f86bb801de6f7c6ff2a454e3db3
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Mon Nov 28 22:01:37 2005 +0000
Change *mandir targets to use new *_MAN_DIR variables set by xorg-macros.m4
update to fix bug #5167 (Linux prefers *.1x man pages in man1 subdir)
commit de9318f27ce26c5362d71a970738db261277a630
Author: Eric Anholt <anholt@freebsd.org>
Date: Mon Nov 21 10:34:55 2005 +0000
Another pass at .cvsignores for apps.
commit 9b58fd72a610a45eb5a93d04d6b7b883ca3b8faf
Author: Eric Anholt <anholt@freebsd.org>
Date: Sun Nov 20 22:08:48 2005 +0000
Add/improve .cvsignore files for apps.
commit cab89641f369a196d4ad7ad23db8e6dfc2257d01
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Sun Nov 20 18:08:14 2005 +0000
iceauth only depends on xproto headers, not x11 library
commit e4b6fddc688dbb65353f818dd482c1a0dd9575f8
Author: Kevin E Martin <kem@kem.org>
Date: Wed Oct 19 02:47:48 2005 +0000
Update package version number for RC1 release.
commit 1ded5d399305e930b7e3dcbb5ca48cbf5018faa7
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Mon Oct 17 23:56:19 2005 +0000
Use @APP_MAN_SUFFIX@ instead of $(APP_MAN_SUFFIX) in macro substitutions to
work better with BSD make
commit a0fcb616a2e44353758f3010769b1e975f7944b9
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Fri Oct 14 00:25:41 2005 +0000
Use sed to fill in variables in man page
commit 973f5b5e29f4ecc43e47799dcd747d67c956edd6
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Mon Aug 1 20:25:27 2005 +0000
Install man pages to section 1 instead of section m (Patch from Donnie
Berkholz)
commit 8f0e8e0af05244c5a10914dc789c97f99e7a2aa3
Author: Kevin E Martin <kem@kem.org>
Date: Fri Jul 29 21:22:29 2005 +0000
Various changes preparing packages for RC0:
- Verify and update package version numbers as needed
- Implement versioning scheme
- Change bug address to point to bugzilla bug entry form
- Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to
reenable it)
- Fix makedepend to use pkgconfig and pass distcheck
- Update build script to build macros first
- Update modular Xorg version
commit ee46a1af27aabf3178af70b02d95356d757572d3
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Tue Jul 26 18:58:14 2005 +0000
Use AC_TYPE_SIGNAL and AC_FUNC_VFORK to replace Imake's SIGNAL_DEFINES and
-DHAS_VFORK
commit c911c36dadcb8070fbdf94d7f9eef494e18b5094
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Tue Jul 26 18:55:42 2005 +0000
Add config.h includes for modularization Use RETSIGTYPE if defined by
autoconf in addition to Imake's SIGNALRETURNSINT. Use
HAVE_WORKING_VFORK if defined by autoconf in addition to Imake's
HAS_VFORK
commit 055e01c0756e6aa8603169dd104cdd2153d2b749
Author: Adam Jackson <ajax@nwnk.net>
Date: Wed Jul 20 19:31:48 2005 +0000
Use a unique token for PKG_CHECK_MODULES. Otherwise, if you use a global
configure cache, you cache it, and the cached value is probably wrong.
commit c83a1200d2480ac67d755e4c589b524d1b834a6a
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Sat Jul 16 20:52:25 2005 +0000
Mark variables modified in signal handlers as volatile (part of Sun bug id
4496504)
commit d0bc63cf13e98f686bd371a0ab609018e7fdf8c2
Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
Date: Tue Jun 28 15:04:15 2005 +0000
Add build system for iceauth
commit 2562a65de3dfa44006c1f82052814d9b54e00f37
Author: Egbert Eich <eich@suse.de>
Date: Fri Apr 23 19:54:33 2004 +0000
Merging XORG-CURRENT into trunk
commit d8eefa5e8a51e448eecb9ec6be656775be2884cd
Author: Egbert Eich <eich@suse.de>
Date: Sun Mar 14 08:34:51 2004 +0000
Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004
commit c560cd34038b23f28862bc890f3aaf161bb64c32
Author: Egbert Eich <eich@suse.de>
Date: Wed Mar 3 12:12:50 2004 +0000
Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004
commit d05d91dcd79d5ce8ce548da80ae6e11eb8a4fcc7
Author: Egbert Eich <eich@suse.de>
Date: Thu Feb 26 13:36:15 2004 +0000
readding XFree86's cvs IDs
commit a833bab02a6cbe19724b6bb4583f4ffaa24a0534
Author: Egbert Eich <eich@suse.de>
Date: Thu Feb 26 09:23:54 2004 +0000
Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004
commit a3101452dc6f4ef01c328fad7e18685363937bcf
Author: Kaleb Keithley <kaleb@freedesktop.org>
Date: Fri Nov 14 16:48:57 2003 +0000
XFree86 4.3.0.1
commit 511f5a05d0cc763d60b6b39584ea29b287cb801c
Author: Kaleb Keithley <kaleb@freedesktop.org>
Date: Fri Nov 14 15:54:52 2003 +0000
R6.6 is the Xorg base-line

View File

@@ -21,7 +21,7 @@
bin_PROGRAMS = iceauth
iceauth_CFLAGS = $(ICEAUTH_CFLAGS)
AM_CFLAGS = $(ICEAUTH_CFLAGS)
iceauth_LDADD = $(ICEAUTH_LIBS)
iceauth_SOURCES = \
@@ -37,9 +37,18 @@ appmandir = $(APP_MAN_DIR)
appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
EXTRA_DIST = $(appman_PRE)
EXTRA_DIST = $(appman_PRE) ChangeLog autogen.sh
CLEANFILES = $(appman_DATA)
MAINTAINERCLEANFILES=ChangeLog
.PHONY: ChangeLog
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
SED = sed
# Strings to replace in man pages
@@ -63,3 +72,10 @@ SUFFIXES = .$(APP_MAN_SUFFIX) .man
.man.$(APP_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
if LINT
ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
lint:
$(LINT) $(ALL_LINT_FLAGS) $(iceauth_SOURCES)
endif LINT

13
app/iceauth/autogen.sh Normal file
View File

@@ -0,0 +1,13 @@
#! /bin/sh
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
$srcdir/configure --enable-maintainer-mode "$@"

View File

@@ -22,12 +22,16 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
AC_INIT(iceauth,[1.0.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],iceauth)
AC_INIT(iceauth,[1.0.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],iceauth)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)
# Require xorg-macros version 1.1.0 or newer for XORG_WITH_LINT macro
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.1)
AC_PROG_CC
AC_PROG_INSTALL
@@ -38,6 +42,7 @@ PKG_CHECK_MODULES(ICEAUTH, xproto ice)
AC_SUBST(ICEAUTH_CFLAGS)
AC_SUBST(ICEAUTH_LIBS)
XORG_WITH_LINT
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION

View File

@@ -37,7 +37,7 @@ in this Software without prior written authorization from The Open Group.
/*
* global data
*/
char *ProgramName; /* argv[0], set at top of main() */
const char *ProgramName; /* argv[0], set at top of main() */
int verbose = -1; /* print certain messages */
Bool ignore_locks = False; /* for error recovery */
Bool break_locks = False; /* for error recovery */
@@ -49,7 +49,7 @@ Bool break_locks = False; /* for error recovery */
static char *authfilename = NULL; /* filename of cookie file */
static char *defcmds[] = { "source", "-", NULL }; /* default command */
static int ndefcmds = 2;
static char *defsource = "(stdin)";
static const char *defsource = "(stdin)";
/*
@@ -57,35 +57,25 @@ static char *defsource = "(stdin)";
*/
static void usage (void)
{
static char *prefixmsg[] = {
"",
"where options include:",
" -f authfilename name of authority file to use",
" -v turn on extra messages",
" -q turn off extra messages",
" -i ignore locks on authority file",
" -b break locks on authority file",
"",
"and commands have the following syntax:",
"",
NULL };
static char *suffixmsg[] = {
"A dash may be used with the \"merge\" and \"source\" to read from the",
"standard input. Commands beginning with \"n\" use numeric format.",
"",
NULL };
char **msg;
static const char prefixmsg[] =
"\n"
"where options include:\n"
" -f authfilename name of authority file to use\n"
" -v turn on extra messages\n"
" -q turn off extra messages\n"
" -i ignore locks on authority file\n"
" -b break locks on authority file\n"
"\n"
"and commands have the following syntax:\n";
static const char suffixmsg[] =
"A dash may be used with the \"merge\" and \"source\" to read from the\n"
"standard input. Commands beginning with \"n\" use numeric format.\n";
fprintf (stderr, "usage: %s [-options ...] [command arg ...]\n",
ProgramName);
for (msg = prefixmsg; *msg; msg++) {
fprintf (stderr, "%s\n", *msg);
}
fprintf (stderr, "%s\n", prefixmsg);
print_help (stderr, " "); /* match prefix indentation */
fprintf (stderr, "\n");
for (msg = suffixmsg; *msg; msg++) {
fprintf (stderr, "%s\n", *msg);
}
fprintf (stderr, "\n%s\n", suffixmsg);
exit (1);
}
@@ -97,7 +87,7 @@ int
main (int argc, char *argv[])
{
int i;
char *sourcename = defsource;
const char *sourcename = defsource;
char **arglist = defcmds;
int nargs = ndefcmds;
int status;

View File

@@ -45,14 +45,14 @@ typedef int Bool;
#define True 1
#endif
extern char *ProgramName;
extern const char *ProgramName;
#include <stdlib.h>
extern int auth_initialize ( char *authfilename );
extern int auth_finalize ( void );
extern int process_command ( char *inputfilename, int lineno, int argc, char **argv );
extern int print_help ( FILE *fp, char *cmd );
extern int process_command ( const char *inputfilename, int lineno, int argc, char **argv );
extern int print_help ( FILE *fp, const char *cmd );
extern int verbose;
extern Bool ignore_locks;

View File

@@ -1,5 +1,4 @@
.\" $Xorg: iceauth.man,v 1.4 2001/02/09 02:05:31 xorgcvs Exp $
.\" Copyright 1994, 1998 The Open Group
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its

View File

@@ -51,8 +51,8 @@ typedef struct _AuthList { /* linked list of entries */
#define add_to_list(h,t,e) {if (t) (t)->next = (e); else (h) = (e); (t) = (e);}
typedef int (*ProcessFunc)(char *, int, int, char **);
typedef int (*DoFunc)(char *, int, IceAuthFileEntry *, char *);
typedef int (*ProcessFunc)(const char *, int, int, char **);
typedef int (*DoFunc)(const char *, int, IceAuthFileEntry *, char *);
typedef struct _CommandTable { /* commands that are understood */
char *name; /* full name */
@@ -80,44 +80,43 @@ struct _list_data { /* for iterating */
*/
static char *stdin_filename = "(stdin)"; /* for messages */
static char *stdout_filename = "(stdout)"; /* for messages */
static char *Yes = "yes"; /* for messages */
static char *No = "no"; /* for messages */
static const char *Yes = "yes"; /* for messages */
static const char *No = "no"; /* for messages */
static char *copystring ( char *src );
static int binaryEqual ( char *a, char *b, unsigned len );
static void prefix ( char *fn, int n );
static void badcommandline ( char *cmd );
static int binaryEqual ( const char *a, const char *b, unsigned len );
static void prefix ( const char *fn, int n );
static void badcommandline ( const char *cmd );
static char *skip_space ( char *s );
static char *skip_nonspace ( char *s );
static char **split_into_words ( char *src, int *argcp );
static FILE *open_file ( char **filenamep, char *mode, Bool *usedstdp, char *srcfn, int srcln, char *cmd );
static FILE *open_file ( char **filenamep, const char *mode, Bool *usedstdp, const char *srcfn, int srcln, const char *cmd );
static int read_auth_entries ( FILE *fp, AuthList **headp, AuthList **tailp );
static int cvthexkey ( char *hexstr, char **ptrp );
static int dispatch_command ( char *inputfilename, int lineno, int argc, char **argv, CommandTable *tab, int *statusp );
static int dispatch_command ( const char *inputfilename, int lineno, int argc, char **argv, const CommandTable *tab, int *statusp );
static void die ( int sig );
static void catchsig ( int sig );
static void register_signals ( void );
static int write_auth_file ( char *tmp_nam );
static void fprintfhex ( FILE *fp, unsigned int len, char *cp );
static int dump_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int extract_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int write_auth_file ( char *tmp_nam, size_t tmp_nam_len );
static void fprintfhex ( FILE *fp, unsigned int len, const char *cp );
static int dump_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int extract_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int match_auth ( IceAuthFileEntry *a, IceAuthFileEntry *b, int *authDataSame );
static int merge_entries ( AuthList **firstp, AuthList *second, int *nnewp, int *nreplp, int *ndupp );
static int search_and_do ( char *inputfilename, int lineno, int start, int argc, char *argv[], DoFunc do_func, char *data );
static int remove_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int do_help ( char *inputfilename, int lineno, int argc, char **argv );
static int do_questionmark ( char *inputfilename, int lineno, int argc, char **argv );
static int do_list ( char *inputfilename, int lineno, int argc, char **argv );
static int do_merge ( char *inputfilename, int lineno, int argc, char **argv );
static int do_extract ( char *inputfilename, int lineno, int argc, char **argv );
static int do_add ( char *inputfilename, int lineno, int argc, char **argv );
static int do_remove ( char *inputfilename, int lineno, int argc, char **argv );
static int do_info ( char *inputfilename, int lineno, int argc, char **argv );
static int do_exit ( char *inputfilename, int lineno, int argc, char **argv );
static int do_quit ( char *inputfilename, int lineno, int argc, char **argv );
static int do_source ( char *inputfilename, int lineno, int argc, char **argv );
static int search_and_do ( const char *inputfilename, int lineno, int start, int argc, char *argv[], DoFunc do_func, char *data );
static int remove_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
static int do_help ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_questionmark ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_list ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_merge ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_extract ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_add ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_remove ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_info ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_exit ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_quit ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_source ( const char *inputfilename, int lineno, int argc, char **argv );
static CommandTable command_table[] = { /* table of known commands */
static const CommandTable command_table[] = { /* table of known commands */
{ "add", 2, 3, do_add,
"\
add add an entry\n\
@@ -186,7 +185,7 @@ source read commands from file\n\
static Bool okay_to_use_stdin = True; /* set to false after using */
static char *hex_table[] = { /* for printing hex digits */
static const char * const hex_table[] = { /* for printing hex digits */
"00", "01", "02", "03", "04", "05", "06", "07",
"08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
"10", "11", "12", "13", "14", "15", "16", "17",
@@ -223,31 +222,20 @@ static char *hex_table[] = { /* for printing hex digits */
static unsigned int hexvalues[256]; /* for parsing hex input */
static int original_umask = 0; /* for restoring */
static mode_t original_umask = 0; /* for restoring */
/*
* private utility procedures
*/
static char *copystring (src)
char *src;
{
int len = strlen (src);
char *cp;
if (!src) return NULL;
cp = malloc (len + 1);
if (cp)
strcpy (cp, src);
return cp;
}
#define copystring(s) ( s != NULL ? strdup(s) : NULL )
static int
binaryEqual (a, b, len)
register char *a, *b;
register unsigned len;
binaryEqual (
register const char *a,
register const char *b,
register unsigned len)
{
while (len--)
@@ -256,21 +244,17 @@ register unsigned len;
return 1;
}
static void prefix (fn, n)
char *fn;
int n;
static void prefix (const char *fn, int n)
{
fprintf (stderr, "%s: %s:%d: ", ProgramName, fn, n);
}
static void badcommandline (cmd)
char *cmd;
static void badcommandline (const char *cmd)
{
fprintf (stderr, "bad \"%s\" command line\n", cmd);
}
static char *skip_space (s)
register char *s;
static char *skip_space (register char *s)
{
if (!s) return NULL;
@@ -280,8 +264,7 @@ static char *skip_space (s)
}
static char *skip_nonspace (s)
register char *s;
static char *skip_nonspace (register char *s)
{
if (!s) return NULL;
@@ -291,9 +274,9 @@ static char *skip_nonspace (s)
return s;
}
static char **split_into_words (src, argcp) /* argvify string */
char *src;
int *argcp;
static char **split_into_words ( /* argvify string */
char *src,
int *argcp)
{
char *jword;
char savec;
@@ -333,13 +316,13 @@ static char **split_into_words (src, argcp) /* argvify string */
}
static FILE *open_file (filenamep, mode, usedstdp, srcfn, srcln, cmd)
char **filenamep;
char *mode;
Bool *usedstdp;
char *srcfn;
int srcln;
char *cmd;
static FILE *open_file (
char **filenamep,
const char *mode,
Bool *usedstdp,
const char *srcfn,
int srcln,
const char *cmd)
{
FILE *fp;
@@ -371,9 +354,7 @@ static FILE *open_file (filenamep, mode, usedstdp, srcfn, srcln, cmd)
}
static int read_auth_entries (fp, headp, tailp)
FILE *fp;
AuthList **headp, **tailp;
static int read_auth_entries (FILE *fp, AuthList **headp, AuthList **tailp)
{
IceAuthFileEntry *auth;
AuthList *head, *tail;
@@ -405,9 +386,9 @@ static int read_auth_entries (fp, headp, tailp)
}
static int cvthexkey (hexstr, ptrp) /* turn hex key string into octets */
char *hexstr;
char **ptrp;
static int cvthexkey ( /* turn hex key string into octets */
char *hexstr,
char **ptrp)
{
int i;
int len = 0;
@@ -457,15 +438,15 @@ static int cvthexkey (hexstr, ptrp) /* turn hex key string into octets */
return len;
}
static int dispatch_command (inputfilename, lineno, argc, argv, tab, statusp)
char *inputfilename;
int lineno;
int argc;
char **argv;
CommandTable *tab;
int *statusp;
static int dispatch_command (
const char *inputfilename,
int lineno,
int argc,
char **argv,
const CommandTable *tab,
int *statusp)
{
CommandTable *ct;
const CommandTable *ct;
char *cmd;
int n;
/* scan table for command */
@@ -506,8 +487,7 @@ static volatile Bool dieing = False;
#define WRITES(fd, S) (void)write((fd), (S), strlen((S)))
/* ARGSUSED */
static _signal_t die (sig)
int sig;
static _signal_t die (int sig)
{
dieing = True;
_exit (auth_finalize ());
@@ -517,8 +497,7 @@ static _signal_t die (sig)
#endif
}
static _signal_t catchsig (sig)
int sig;
static _signal_t catchsig (int sig)
{
#ifdef SYSV
if (sig > 0) signal (sig, die); /* re-establish signal handler */
@@ -539,7 +518,7 @@ static _signal_t catchsig (sig)
#endif
}
static void register_signals ()
static void register_signals (void)
{
signal (SIGINT, catchsig);
signal (SIGTERM, catchsig);
@@ -554,8 +533,7 @@ static void register_signals ()
* public procedures for parsing lines of input
*/
int auth_initialize (authfilename)
char *authfilename;
int auth_initialize ( char *authfilename )
{
int n;
AuthList *head, *tail;
@@ -587,6 +565,8 @@ int auth_initialize (authfilename)
authfilename);
}
iceauth_filename = strdup(authfilename);
if (ignore_locks) {
if (break_locks) IceUnlockAuthFile (authfilename);
} else {
@@ -645,9 +625,6 @@ int auth_initialize (authfilename)
iceauth_head = head;
}
n = strlen (authfilename);
iceauth_filename = malloc (n + 1);
if (iceauth_filename) strcpy (iceauth_filename, authfilename);
iceauth_modified = False;
if (verbose) {
@@ -657,12 +634,17 @@ int auth_initialize (authfilename)
return 0;
}
static int write_auth_file (tmp_nam)
char *tmp_nam;
static int write_auth_file (char *tmp_nam, size_t tmp_nam_len)
{
FILE *fp;
AuthList *list;
if ((strlen(iceauth_filename) + 3) > tmp_nam_len) {
strncpy(tmp_nam, "filename too long", tmp_nam_len);
tmp_nam[tmp_nam_len - 1] = '\0';
return -1;
}
strcpy (tmp_nam, iceauth_filename);
strcat (tmp_nam, "-n"); /* for new */
(void) unlink (tmp_nam);
@@ -680,7 +662,7 @@ static int write_auth_file (tmp_nam)
return 0;
}
int auth_finalize ()
int auth_finalize (void)
{
char temp_name[1024]; /* large filename size */
@@ -713,7 +695,7 @@ int auth_finalize ()
"Writing", iceauth_filename);
}
temp_name[0] = '\0';
if (write_auth_file (temp_name) == -1) {
if (write_auth_file (temp_name, sizeof(temp_name)) == -1) {
fprintf (stderr,
"%s: unable to write authority file %s\n",
ProgramName, temp_name);
@@ -735,18 +717,18 @@ int auth_finalize ()
}
}
if (!ignore_locks) {
if (!ignore_locks && (iceauth_filename != NULL)) {
IceUnlockAuthFile (iceauth_filename);
}
(void) umask (original_umask);
return 0;
}
int process_command (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
int process_command (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int status;
@@ -766,15 +748,15 @@ int process_command (inputfilename, lineno, argc, argv)
* utility routines
*/
static void fprintfhex (fp, len, cp)
register FILE *fp;
unsigned int len;
char *cp;
static void fprintfhex (
register FILE *fp,
unsigned int len,
const char *cp)
{
unsigned char *ucp = (unsigned char *) cp;
const unsigned char *ucp = (const unsigned char *) cp;
for (; len > 0; len--, ucp++) {
register char *s = hex_table[*ucp];
register const char *s = hex_table[*ucp];
putc (s[0], fp);
putc (s[1], fp);
}
@@ -782,11 +764,11 @@ static void fprintfhex (fp, len, cp)
}
/* ARGSUSED */
static int dump_entry (inputfilename, lineno, auth, data)
char *inputfilename;
int lineno;
IceAuthFileEntry *auth;
char *data;
static int dump_entry (
const char *inputfilename,
int lineno,
IceAuthFileEntry *auth,
char *data)
{
struct _list_data *ld = (struct _list_data *) data;
FILE *fp = ld->fp;
@@ -815,11 +797,11 @@ static int dump_entry (inputfilename, lineno, auth, data)
return 0;
}
static int extract_entry (inputfilename, lineno, auth, data)
char *inputfilename;
int lineno;
IceAuthFileEntry *auth;
char *data;
static int extract_entry (
const char *inputfilename,
int lineno,
IceAuthFileEntry *auth,
char *data)
{
struct _extract_data *ed = (struct _extract_data *) data;
@@ -842,9 +824,10 @@ static int extract_entry (inputfilename, lineno, auth, data)
}
static int match_auth (a, b, authDataSame)
register IceAuthFileEntry *a, *b;
int *authDataSame;
static int match_auth (
register IceAuthFileEntry *a,
register IceAuthFileEntry *b,
int *authDataSame)
{
int match = strcmp (a->protocol_name, b->protocol_name) == 0 &&
strcmp (a->network_id, b->network_id) == 0 &&
@@ -862,9 +845,9 @@ static int match_auth (a, b, authDataSame)
}
static int merge_entries (firstp, second, nnewp, nreplp, ndupp)
AuthList **firstp, *second;
int *nnewp, *nreplp, *ndupp;
static int merge_entries (
AuthList **firstp, AuthList *second,
int *nnewp, int *nreplp, int *ndupp)
{
AuthList *a, *b, *first, *tail;
int n = 0, nnew = 0, nrepl = 0, ndup = 0;
@@ -950,15 +933,14 @@ static int merge_entries (firstp, second, nnewp, nreplp, ndupp)
}
static int search_and_do (inputfilename, lineno, start,
argc, argv, do_func, data)
char *inputfilename;
int lineno;
int start;
int argc;
char *argv[];
DoFunc do_func;
char *data;
static int search_and_do (
const char *inputfilename,
int lineno,
int start,
int argc,
char *argv[],
DoFunc do_func,
char *data)
{
int i;
int status = 0;
@@ -1016,11 +998,11 @@ static int search_and_do (inputfilename, lineno, start,
/* ARGSUSED */
static int remove_entry (inputfilename, lineno, auth, data)
char *inputfilename;
int lineno;
IceAuthFileEntry *auth;
char *data;
static int remove_entry (
const char *inputfilename,
int lineno,
IceAuthFileEntry *auth,
char *data)
{
int *nremovedp = (int *) data;
AuthList **listp = &iceauth_head;
@@ -1046,11 +1028,11 @@ static int remove_entry (inputfilename, lineno, auth, data)
/*
* help
*/
int print_help (fp, cmd)
FILE *fp;
char *cmd;
int print_help (
FILE *fp,
const char *cmd)
{
CommandTable *ct;
const CommandTable *ct;
int n = 0;
fprintf (fp, "\n");
@@ -1072,11 +1054,11 @@ int print_help (fp, cmd)
return n;
}
static int do_help (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_help (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
char *cmd = (argc > 1 ? argv[1] : NULL);
int n;
@@ -1106,13 +1088,13 @@ static int do_help (inputfilename, lineno, argc, argv)
* questionmark
*/
/* ARGSUSED */
static int do_questionmark (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_questionmark (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
CommandTable *ct;
const CommandTable *ct;
int i;
#define WIDEST_COLUMN 72
int col = WIDEST_COLUMN;
@@ -1144,11 +1126,11 @@ static int do_questionmark (inputfilename, lineno, argc, argv)
/*
* list [displayname ...]
*/
static int do_list (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_list (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
struct _list_data ld;
@@ -1174,11 +1156,11 @@ static int do_list (inputfilename, lineno, argc, argv)
/*
* merge filename [filename ...]
*/
static int do_merge (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_merge (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int i;
int errors = 0;
@@ -1238,11 +1220,11 @@ static int do_merge (inputfilename, lineno, argc, argv)
/*
* extract filename displayname [displayname ...]
*/
static int do_extract (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_extract (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int errors;
struct _extract_data ed;
@@ -1282,11 +1264,11 @@ static int do_extract (inputfilename, lineno, argc, argv)
/*
* add protoname protodata netid authname authdata
*/
static int do_add (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_add (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int n, nnew, nrepl, ndup;
char *protoname;
@@ -1295,7 +1277,7 @@ static int do_add (inputfilename, lineno, argc, argv)
char *netid;
char *authname;
char *authdata_hex;
char *authdata;
char *authdata = NULL;
int protodata_len, authdata_len;
IceAuthFileEntry *auth = NULL;
AuthList *list;
@@ -1447,14 +1429,14 @@ cant_add:
{
if (auth->protocol_name)
free (auth->protocol_name);
if (auth->protocol_data)
free (auth->protocol_data);
/* auth->protocol_data already freed,
since it's the same as protodata */
if (auth->network_id)
free (auth->network_id);
if (auth->auth_name)
free (auth->auth_name);
if (auth->auth_data)
free (auth->auth_data);
/* auth->auth_data already freed,
since it's the same as authdata */
free ((char *) auth);
}
@@ -1464,11 +1446,11 @@ cant_add:
/*
* remove displayname
*/
static int do_remove (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_remove (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int nremoved = 0;
int errors;
@@ -1488,11 +1470,11 @@ static int do_remove (inputfilename, lineno, argc, argv)
/*
* info
*/
static int do_info (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_info (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
int n;
AuthList *l;
@@ -1523,11 +1505,11 @@ static int do_info (inputfilename, lineno, argc, argv)
static Bool alldone = False;
/* ARGSUSED */
static int do_exit (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_exit (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
/* allow bogus stuff */
alldone = True;
@@ -1538,11 +1520,11 @@ static int do_exit (inputfilename, lineno, argc, argv)
* quit
*/
/* ARGSUSED */
static int do_quit (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_quit (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
/* allow bogus stuff */
die (0);
@@ -1554,11 +1536,11 @@ static int do_quit (inputfilename, lineno, argc, argv)
/*
* source filename
*/
static int do_source (inputfilename, lineno, argc, argv)
char *inputfilename;
int lineno;
int argc;
char **argv;
static int do_source (
const char *inputfilename,
int lineno,
int argc,
char **argv)
{
char *script;
char buf[BUFSIZ];