DO NOT COMMIT, I will seperate this in files with specific changes.
- (void) and register removal
- security fixes
- WARNS=6 fixes

Index: defs.h
===================================================================
RCS file: /cvs/src/usr.bin/rdist/defs.h,v
retrieving revision 1.5
diff -u -r1.5 defs.h
--- defs.h	24 Jul 2004 19:45:10 -0000	1.5
+++ defs.h	25 Aug 2004 18:15:15 -0000
@@ -178,7 +178,7 @@
 void	 insert(char *,
 	    struct namelist *, struct namelist *, struct subcmd *);
 void	 install(char *, char *, int, int);
-void	 log(FILE *, const char *, ...);
+void	 dolog(FILE *, const char *, ...);
 struct namelist *
 	 lookup(char *, int, struct namelist *);
 void	 lostconn(int);
Index: docmd.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/docmd.c,v
retrieving revision 1.4
diff -u -r1.4 docmd.c
--- docmd.c	24 Jul 2004 19:45:10 -0000	1.4
+++ docmd.c	25 Aug 2004 23:48:54 -0000
@@ -65,9 +65,9 @@
 void
 docmds(char **dhosts, int argc, char **argv)
 {
-	register struct cmd *c;
-	register struct namelist *f;
-	register char **cpp;
+	struct cmd *c;
+	struct namelist *f;
+	char **cpp;
 	extern struct cmd *cmds;
 
 	signal(SIGHUP, cleanup);
@@ -118,13 +118,13 @@
 static void
 doarrow(char **filev, struct namelist *files, char *rhost, struct subcmd *cmds)
 {
-	register struct namelist *f;
-	register struct subcmd *sc;
-	register char **cpp;
+	struct namelist *f;
+	struct subcmd *sc;
+	char **cpp;
 	int n, ddir, opts = options;
 
 	if (debug)
-		printf("doarrow(%p, %s, %p)\n", files, rhost, cmds);
+		printf("doarrow(%p, %s, %p)\n", (long)files, rhost, (long)cmds);
 
 	if (files == NULL) {
 		error("no files to be updated\n");
@@ -179,16 +179,14 @@
 		if (sc->sc_type == NOTIFY)
 			notify(tempfile, rhost, sc->sc_args, 0);
 	if (!nflag) {
-		struct linkbuf *nextihead;
-
 		unlink(tempfile);
-		for (; ihead != NULL; ihead = nextihead) {
-			nextihead = ihead->nextp;
+		for (; ihead != NULL; ihead = ihead->nextp) {
+			free(ihead);
 			if ((opts & IGNLNKS) || ihead->count == 0)
 				continue;
-			log(lfp, "%s: Warning: missing links\n",
-				ihead->pathname);
-			free(ihead);
+			if (lfp)
+				dolog(lfp, "%s: Warning: missing links\n",
+					ihead->pathname);
 		}
 	}
 }
@@ -244,7 +242,7 @@
 static int
 makeconn(char *rhost)
 {
-	register char *ruser, *cp;
+	char *ruser, *cp;
 	static char *cur_host = NULL;
 	static int port = -1;
 	char tuser[20];
@@ -263,12 +261,15 @@
 		closeconn();
 	}
 	cur_host = rhost;
-	cp = index(rhost, '@');
+	cp = strchr(rhost, '@');
 	if (cp != NULL) {
 		char c = *cp;
 
 		*cp = '\0';
-		strncpy(tuser, rhost, sizeof(tuser)-1);
+		if (strlcpy(tuser, rhost, sizeof(tuser)) >= sizeof(tuser)) {
+			*cp = c;
+			return(0);
+		}
 		*cp = c;
 		rhost = cp + 1;
 		ruser = tuser;
@@ -352,15 +353,18 @@
 {
 	if (iamremote)
 		cleanup(0);
-	log(lfp, "rdist: lost connection\n");
+	if (lfp)
+		dolog(lfp, "rdist: lost connection\n");
+	else
+		error("lost connection\n");
 	longjmp(env, 1);
 }
 
 static int
-okname(register char *name)
+okname(char *name)
 {
-	register char *cp;
-	register int c;
+	char *cp;
+	int c;
 
 	cp = name;
 
@@ -388,9 +392,9 @@
 static void
 dodcolon(char **filev, struct namelist *files, char *stamp, struct subcmd *cmds)
 {
-	register struct subcmd *sc;
-	register struct namelist *f;
-	register char **cpp;
+	struct subcmd *sc;
+	struct namelist *f;
+	char **cpp;
 	struct timeval tv[2];
 	struct timezone tz;
 	struct stat stb;
@@ -407,7 +411,7 @@
 		return;
 	}
 	if (debug)
-		printf("%s: %ld\n", stamp, stb.st_mtime);
+		printf("%s: %lu\n", stamp, (u_long)stb.st_mtime);
 
 	subcmds = cmds;
 	lastmod = stb.st_mtime;
@@ -492,15 +496,15 @@
 	}
 
 	if (stb.st_mtime > lastmod)
-		log(tfp, "new: %s\n", name);
+		dolog(tfp, "new: %s\n", name);
 }
 
 static void
 rcmptime(struct stat *st)
 {
-	register DIR *d;
-	register struct dirent *dp;
-	register char *cp;
+	DIR *d;
+	struct dirent *dp;
+	char *cp;
 	char *otp;
 	int len;
 
@@ -539,14 +543,22 @@
  * stamp file.
  */
 static void
-notify(char *file, char *rhost, register struct namelist *to, time_t lmod)
+notify(char *file, char *rhost, struct namelist *to, time_t lmod)
 {
-	register int fd, len;
+	int fd, len;
 	struct stat stb;
 	FILE *pf;
+	char *cp, *nrhost;
+
+	nrhost = rhost;
 
 	if ((options & VERIFY) || to == NULL)
 		return;
+
+	/* strip any leading user@ prefix from rhost */
+	if (rhost && (cp = strchr(rhost, '@')) != NULL)
+		nrhost = cp + 1;
+
 	if (!qflag) {
 		printf("notify ");
 		if (rhost)
@@ -570,7 +582,7 @@
 		return;
 	}
 	/*
-	 * Create a pipe to mailling program.
+	 * Create a pipe to mailing program.
 	 */
 	snprintf(buf, sizeof(buf), "%s -oi -t", _PATH_SENDMAIL);
 	pf = popen(buf, "w");
@@ -617,7 +629,7 @@
 int
 inlist(struct namelist *list, char *file)
 {
-	register struct namelist *nl;
+	struct namelist *nl;
 
 	for (nl = list; nl != NULL; nl = nl->n_next)
 		if (!strcmp(file, nl->n_name))
@@ -631,10 +643,10 @@
 int
 except(char *file)
 {
-	register struct	subcmd *sc;
-	register struct	namelist *nl;
+	struct	subcmd *sc;
+	struct	namelist *nl;
 	regex_t rx;
-	int val;
+	int err;
 
 	if (debug)
 		printf("except(%s)\n", file);
@@ -648,8 +660,11 @@
 					return(1);
 				continue;
 			}
-			val = regcomp(&rx, nl->n_name,
-				      REG_EXTENDED | REG_NOSUB);
+			if ((err = regcomp(&rx, nl->n_name, REG_EXTENDED | REG_NOSUB)) != 0) {
+				char ebuf[BUFSIZ];
+				regerror(err, &rx, ebuf, sizeof(ebuf));
+				error("%s: %s\n", nl->n_name, ebuf);
+			}
 			if (!regexec(&rx, file, 0, 0, 0)) {
 				regfree(&rx);
 				return 1;
@@ -661,7 +676,7 @@
 }
 
 char *
-colon(register char *cp)
+colon(char *cp)
 {
 
 	while (*cp) {
Index: expand.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/expand.c,v
retrieving revision 1.4
diff -u -r1.4 expand.c
--- expand.c	24 Jul 2004 19:45:10 -0000	1.4
+++ expand.c	26 Aug 2004 00:21:57 -0000
@@ -83,18 +83,18 @@
 struct namelist *
 expand(struct namelist *list, int wh)
 {
-	register struct namelist *nl, *prev;
-	register int n;
+	struct namelist *nl, *prev;
+	int n;
 	char pathbuf[BUFSIZ];
 	char *argvbuf[GAVSIZ];
 
 	if (debug) {
-		printf("expand(%p, %d)\nlist = ", list, wh);
+		printf("expand(%p, %d)\nlist = ", (long)list, wh);
 		prnames(list);
 	}
 
 	if (wh == 0) {
-		register char *cp;
+		char *cp;
 
 		for (nl = list; nl != NULL; nl = nl->n_next)
 			for (cp = nl->n_name; *cp; cp++)
@@ -140,8 +140,8 @@
 static void
 expstr(char *s)
 {
-	register char *cp, *cp1;
-	register struct namelist *tp;
+	char *cp, *cp1;
+	struct namelist *tp;
 	char *tail;
 	char buf[BUFSIZ];
 	int savec, oeargc;
@@ -150,7 +150,7 @@
 	if (s == NULL || *s == '\0')
 		return;
 
-	if ((which & E_VARS) && (cp = index(s, '$')) != NULL) {
+	if ((which & E_VARS) && (cp = strchr(s, '$')) != NULL) {
 		*cp++ = '\0';
 		if (*cp == '\0') {
 			yyerror("no variable name after '$'");
@@ -158,7 +158,7 @@
 		}
 		if (*cp == LC) {
 			cp++;
-			if ((tail = index(cp, RC)) == NULL) {
+			if ((tail = strchr(cp, RC)) == NULL) {
 				yyerror("unmatched '{'");
 				return;
 			}
@@ -206,7 +206,7 @@
 			*cp1 = '\0';
 			if (pw == NULL || strcmp(pw->pw_name, buf+1) != 0) {
 				if ((pw = getpwnam(buf+1)) == NULL) {
-					strcat(buf, ": unknown user name");
+					strlcat(buf, ": unknown user name",sizeof(buf));
 					yyerror(buf+1);
 					return;
 				}
@@ -252,8 +252,8 @@
 static void
 expsh(char *s)
 {
-	register char *cp;
-	register char *spathp, *oldcp;
+	char *cp;
+	char *spathp, *oldcp;
 	struct stat stb;
 
 	spathp = pathp;
@@ -290,7 +290,7 @@
 matchdir(char *pattern)
 {
 	struct stat stb;
-	register struct dirent *dp;
+	struct dirent *dp;
 	DIR *dirp;
 
 	dirp = opendir(path);
@@ -310,7 +310,7 @@
 			if (which & E_TILDE)
 				Cat(path, dp->d_name);
 			else {
-				strcpy(pathp, dp->d_name);
+				strlcpy(pathp, dp->d_name, lastpathp - pathp + 2);
 				Cat(tilde, tpathp);
 				*pathp = '\0';
 			}
@@ -321,8 +321,8 @@
 patherr1:
 	closedir(dirp);
 patherr2:
-	strcat(path, ": ");
-	strcat(path, strerror(errno));
+	strlcat(path, ": ", lastpathp - path + 2);
+	strlcat(path, strerror(errno), lastpathp - path + 2);
 	yyerror(path);
 }
 
@@ -330,7 +330,7 @@
 execbrc(char *p, char *s)
 {
 	char restbuf[BUFSIZ + 2];
-	register char *pe, *pm, *pl;
+	char *pe, *pm, *pl;
 	int brclev;
 	char *lm, savec, *spathp;
 
@@ -383,8 +383,9 @@
 doit:
 			savec = *pm;
 			*pm = 0;
-			strcpy(lm, pl);
-			strcat(restbuf, pe + 1);
+			*lm = 0;
+			strlcat((char *)restbuf, (char *)pl, sizeof(restbuf));
+			strlcat((char *)restbuf, (char *)pe + 1, sizeof(restbuf));
 			*pm = savec;
 			if (s == 0) {
 				spathp = pathp;
@@ -410,8 +411,8 @@
 static int
 match(char *s, char *p)
 {
-	register int c;
-	register char *sentp;
+	int c;
+	char *sentp;
 	char sexpany;
 
 	sexpany = expany;
@@ -426,9 +427,9 @@
 }
 
 static int
-amatch(register char *s, register char *p)
+amatch(char *s, char *p)
 {
-	register int scc;
+	int scc;
 	int ok, lc, c, cc;
 	char *spathp;
 	struct stat stb;
@@ -514,9 +515,9 @@
 }
 
 static int
-smatch(register char *s, register char *p)
+smatch(char *s, char *p)
 {
-	register int scc;
+	int scc;
 	int ok, lc, c, cc;
 
 	for (;;) {
@@ -571,10 +572,10 @@
 }
 
 static void
-Cat(register char *s1, register char *s2)
+Cat(char *s1, char *s2)
 {
 	int len;
-	register char *s;
+	char *s;
 
 	len = strlen(s1) + strlen(s2) + 1;
 	nleft -= len;
@@ -609,9 +610,9 @@
  * part corresponding to `file'.
  */
 char *
-exptilde(char buf[], register char *file, int maxlen)
+exptilde(char buf[], char *file, int maxlen)
 {
-	register char *s1, *s2, *s3;
+	char *s1, *s2, *s3;
 	extern char homedir[];
 
 	if (strlen(file) >= maxlen)
Index: gram.y
===================================================================
RCS file: /cvs/src/usr.bin/rdist/gram.y,v
retrieving revision 1.4
diff -u -r1.4 gram.y
--- gram.y	24 Jul 2004 19:45:10 -0000	1.4
+++ gram.y	26 Aug 2004 00:52:35 -0000
@@ -141,7 +141,7 @@
 		;
 
 cmd:		  INSTALL options opt_namelist SM = {
-			register struct namelist *nl;
+			struct namelist *nl;
 
 			$1->sc_options = $2 | options;
 			if ($3 != NULL) {
@@ -217,8 +217,8 @@
 yylex()
 {
 	static char yytext[INMAX];
-	register int c;
-	register char *cp1, *cp2;
+	int c;
+	char *cp1, *cp2;
 	static char quotechars[] = "[]{}*?$";
 	
 again:
@@ -365,7 +365,7 @@
 }
 
 int
-any(register int c, register char *str)
+any(int c, char *str)
 {
 	while (*str)
 		if (c == *str++)
@@ -379,8 +379,8 @@
 void
 insert(char *label, struct namelist *files, struct namelist *hosts, struct subcmd *subcmds)
 {
-	register struct cmd *c, *prev, *nc;
-	register struct namelist *h, *next_h;
+	struct cmd *c, *prev, *nc;
+	struct namelist *h, *next_h;
 
 	files = expand(files, E_VARS|E_SHELL);
 	hosts = expand(hosts, E_ALL);
@@ -427,7 +427,7 @@
 void
 append(char *label, struct namelist *files, char *stamp, struct subcmd *subcmds)
 {
-	register struct cmd *c;
+	struct cmd *c;
 
 	c = ALLOC(cmd);
 	if (c == NULL)
@@ -464,7 +464,7 @@
 static char *
 makestr(char *str)
 {
-	register char *cp, *s;
+	char *cp, *s;
 
 	str = cp = malloc(strlen(s = str) + 1);
 	if (cp == NULL)
@@ -480,7 +480,7 @@
 struct namelist *
 makenl(char *name)
 {
-	register struct namelist *nl;
+	struct namelist *nl;
 
 	nl = ALLOC(namelist);
 	if (nl == NULL)
@@ -496,7 +496,7 @@
 struct subcmd *
 makesubcmd(int type)
 {
-	register struct subcmd *sc;
+	struct subcmd *sc;
 
 	sc = ALLOC(subcmd);
 	if (sc == NULL)
Index: lookup.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/lookup.c,v
retrieving revision 1.3
diff -u -r1.3 lookup.c
--- lookup.c	24 Jul 2004 19:45:10 -0000	1.3
+++ lookup.c	26 Aug 2004 00:22:26 -0000
@@ -56,8 +56,8 @@
 void
 define(char *name)
 {
-	register char *cp, *s;
-	register struct namelist *nl;
+	char *cp, *s;
+	struct namelist *nl;
 	struct namelist *value;
 
 	value = NULL;
@@ -65,7 +65,7 @@
 	if (debug)
 		printf("define(%s)\n", name);
 
-	cp = index(name, '=');
+	cp = strchr(name, '=');
 	if (cp == NULL)
 		value = NULL;
 	else if (cp[1] == '\0') {
@@ -120,9 +120,9 @@
 struct namelist *
 lookup(char *name, int action, struct namelist *value)
 {
-	register unsigned n;
-	register char *cp;
-	register struct syment *s;
+	unsigned n;
+	char *cp;
+	struct syment *s;
 	char buf[BUFSIZ];
 
 	if (debug)
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/main.c,v
retrieving revision 1.4
diff -u -r1.4 main.c
--- main.c	24 Jul 2004 19:45:10 -0000	1.4
+++ main.c	26 Aug 2004 00:37:00 -0000
@@ -75,9 +75,10 @@
 int
 main(int argc, char **argv)
 {
-	register char *arg;
+	char *arg;
 	int cmdargs;
 	char *dhosts[NHOSTS], **hp = dhosts;
+	int fd;
 
 	cmdargs = 0;
 
@@ -86,13 +87,14 @@
 		fprintf(stderr, "%s: Who are you?\n", argv[0]);
 		exit(1);
 	}
-	strcpy(user, pw->pw_name);
-	strcpy(homedir, pw->pw_dir);
+	strlcpy(user, pw->pw_name, sizeof(user));
+	strlcpy(homedir, pw->pw_dir, sizeof(homedir));
 	groupid = pw->pw_gid;
 	gethostname(host, sizeof(host));
-	strcpy(tempfile, _PATH_TMP);
-	strcat(tempfile, _RDIST_TMP);
-	if ((tempname = rindex(tempfile, '/')) != 0)
+	host[sizeof(host) - 1] = '\0';
+	strlcpy(tempfile, _PATH_TMP, sizeof(tempfile));
+	strlcat(tempfile, _RDIST_TMP, sizeof(tempfile));
+	if ((tempname = strrchr(tempfile, '/')) != 0)
 		tempname++;
 	else
 		tempname = tempfile;
@@ -193,7 +195,10 @@
 	*hp = NULL;
 
 	seteuid(userid);
-	mktemp(tempfile);
+	fd = mkstemp(tempfile);
+	if (fd == -1)
+		err(1, "could not make a temporary file");
+	close (fd);
 
 	if (iamremote) {
 		server();
@@ -238,8 +243,8 @@
 static void
 docmdargs(int nargs, char **args)
 {
-	register struct namelist *nl, *prev;
-	register char *cp;
+	struct namelist *nl, *prev;
+	char *cp;
 	struct namelist *files, *hosts;
 	struct subcmd *cmds;
 	char *dest;
@@ -263,7 +268,7 @@
 	}
 
 	cp = args[i];
-	if ((dest = index(cp, ':')) != NULL)
+	if ((dest = strchr(cp, ':')) != NULL)
 		*dest++ = '\0';
 	tnl.n_name = cp;
 	hosts = expand(&tnl, E_ALL);
@@ -292,7 +297,7 @@
  * Print a list of NAME blocks (mostly for debugging).
  */
 void
-prnames(register struct namelist *nl)
+prnames(struct namelist *nl)
 {
 	printf("( ");
 	while (nl != NULL) {
Index: server.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/server.c,v
retrieving revision 1.5
diff -u -r1.5 server.c
--- server.c	24 Jul 2004 19:50:42 -0000	1.5
+++ server.c	26 Aug 2004 01:03:03 -0000
@@ -82,10 +82,10 @@
  *	Qname	- Query if file exists. Return mtime & size if it does.
  */
 void
-server()
+server(void)
 {
 	char cmdbuf[BUFSIZ];
-	register char *cp;
+	char *cp;
 
 	signal(SIGHUP, cleanup);
 	signal(SIGINT, cleanup);
@@ -206,7 +206,7 @@
 			continue;
 
 		case 'L':  /* Log. save message in log file */
-			log(lfp, cp);
+			dolog(lfp, cp);
 			continue;
 #endif
 
@@ -236,16 +236,13 @@
 	char *rname;
 	char destcopy[BUFSIZ];
 
-	if (opts & WHOLE)
-		source[0] = '\0';
-	else
-		strcpy(source, src);
-
 	if (dest == NULL) {
 		opts &= ~WHOLE; /* WHOLE mode only useful if renaming */
 		dest = src;
 	}
 
+	strlcpy(destcopy, dest, sizeof(destcopy));
+	
 	if (nflag || debug) {
 		printf("%s%s%s%s%s %s %s\n", opts & VERIFY ? "verify":"install",
 			opts & WHOLE ? " -w" : "",
@@ -264,7 +261,7 @@
 		tp++;
 	/*
 	 * If we are renaming a directory and we want to preserve
-	 * the directory heirarchy (-w), we must strip off the leading
+	 * the directory hierarchy (-w), we must strip off the leading
 	 * directory name and preserve the rest.
 	 */
 	if (opts & WHOLE) {
@@ -272,7 +269,7 @@
 			rname++;
 		destdir = 1;
 	} else {
-		rname = rindex(target, '/');
+		rname = strrchr(target, '/');
 		if (rname == NULL)
 			rname = target;
 		else
@@ -286,7 +283,9 @@
 	snprintf(buf, sizeof(buf), "%c%s\n", destdir ? 'T' : 't', dest);
 	if (debug)
 		printf("buf = %s", buf);
-	write(rem, buf, strlen(buf));
+	if (write(rem, buf, strlen(buf)) < 0)
+		error("could not pass filename to remote: %s\n",
+		    strerror(errno));
 	if (response() < 0)
 		return;
 
@@ -296,10 +295,9 @@
 	 * are not the same.  This info will be used later for maintaining
 	 * hardlink info.
 	 */
-	if (destdir || (src && dest && strcmp(src, dest))) {
-		strcpy(destcopy, dest);
+	if (destdir || (src && dest && strcmp(src, dest)))
 		Tdest = destcopy;
-	}
+
 	sendf(rname, opts);
 	Tdest = 0;
 }
@@ -346,7 +344,7 @@
 static void
 sendf(char *rname, int opts)
 {
-	register struct subcmd *sc;
+	struct subcmd *sc;
 	struct stat stb;
 	int sizerr, f, u, len;
 	off_t i;
@@ -373,24 +371,24 @@
 
 	if (pw == NULL || pw->pw_uid != stb.st_uid)
 		if ((pw = getpwuid(stb.st_uid)) == NULL) {
-			log(lfp, "%s: no password entry for uid %d \n",
+			dolog(lfp, "%s: no password entry for uid %d \n",
 				target, stb.st_uid);
 			pw = NULL;
 			snprintf(user, sizeof(user), ":%lu", stb.st_uid);
 		}
 	if (gr == NULL || gr->gr_gid != stb.st_gid)
 		if ((gr = getgrgid(stb.st_gid)) == NULL) {
-			log(lfp, "%s: no name for group %d\n",
+			dolog(lfp, "%s: no name for group %d\n",
 				target, stb.st_gid);
 			gr = NULL;
 			snprintf(group, sizeof(group), ":%lu", stb.st_gid);
 		}
 	if (u == 1) {
 		if (opts & VERIFY) {
-			log(lfp, "need to install: %s\n", target);
+			dolog(lfp, "need to install: %s\n", target);
 			goto dospecial;
 		}
-		log(lfp, "installing: %s\n", target);
+		dolog(lfp, "installing: %s\n", target);
 		opts &= ~(COMPARE|REMOVE);
 	}
 
@@ -476,10 +474,10 @@
 
 	if (u == 2) {
 		if (opts & VERIFY) {
-			log(lfp, "need to update: %s\n", target);
+			dolog(lfp, "need to update: %s\n", target);
 			goto dospecial;
 		}
-		log(lfp, "updating: %s\n", target);
+		dolog(lfp, "updating: %s\n", target);
 	}
 
 	if (stb.st_nlink > 1) {
@@ -530,7 +528,7 @@
 			continue;
 		if (sc->sc_args != NULL && !inlist(sc->sc_args, target))
 			continue;
-		log(lfp, "special \"%s\"\n", sc->sc_name);
+		dolog(lfp, "special \"%s\"\n", sc->sc_name);
 		if (opts & VERIFY)
 			continue;
 		snprintf(buf, sizeof(buf), "SFILE=%s;%s\n", target,
@@ -555,17 +553,17 @@
 		}
 	lp = (struct linkbuf *) malloc(sizeof(*lp));
 	if (lp == NULL)
-		log(lfp, "out of memory, link information lost\n");
+		dolog(lfp, "out of memory, link information lost\n");
 	else {
 		lp->nextp = ihead;
 		ihead = lp;
 		lp->inum = stp->st_ino;
 		lp->devnum = stp->st_dev;
 		lp->count = stp->st_nlink - 1;
-		strcpy(lp->pathname, target);
-		strcpy(lp->src, source);
+		strlcpy(lp->pathname, target, sizeof(lp->pathname));
+		strlcpy(lp->src, source, sizeof(lp->src));
 		if (Tdest)
-			strcpy(lp->target, Tdest);
+			strlcpy(lp->target, Tdest, sizeof(lp->target));
 		else
 			*lp->target = 0;
 	}
@@ -580,9 +578,9 @@
 static int
 update(char *rname, int opts, struct stat *stp)
 {
-	register char *cp, *s;
-	register off_t size;
-	register time_t mtime;
+	char *cp, *s;
+	off_t size;
+	time_t mtime;
 
 	if (debug)
 		printf("update(%s, %x, %p)\n", rname, opts, stp);
@@ -623,7 +621,7 @@
 	case '\3':
 		*--cp = '\0';
 		if (lfp != NULL)
-			log(lfp, "update: note: %s\n", s);
+			dolog(lfp, "update: note: %s\n", s);
 		goto again;
 
 	default:
@@ -659,7 +657,7 @@
 		if (stp->st_mtime == mtime)
 			return(0);
 		if (stp->st_mtime < mtime) {
-			log(lfp, "Warning: %s: remote copy is newer\n", target);
+			dolog(lfp, "Warning: %s: remote copy is newer\n", target);
 			return(0);
 		}
 	} else if (stp->st_mtime == mtime && stp->st_size == size)
@@ -714,7 +712,7 @@
 static void
 recvf(char *cmd, int type)
 {
-	register char *cp;
+	char *cp;
 	int f, mode, opts, wrerr, olderrno;
 	off_t i, size;
 	time_t mtime;
@@ -816,9 +814,9 @@
 
 	if (catname)
 		snprintf(tp, sizeof(target) - (tp - target), "/%s", cp);
-	cp = rindex(target, '/');
+	cp = strrchr(target, '/');
 	if (cp == NULL)
-		strcpy(new, tempname);
+		strlcpy(new, tempname, sizeof(new));
 	else if (cp == target)
 		snprintf(new, sizeof(new), "/%s", tempname);
 	else {
@@ -970,7 +968,7 @@
 static void
 hardlink(char *cmd)
 {
-	register char *cp;
+	char *cp;
 	struct stat stb;
 	char *oldname;
 	int opts, exists;
@@ -1028,10 +1026,10 @@
 static int
 chkparent(char *name)
 {
-	register char *cp;
+	char *cp;
 	struct stat stb;
 
-	cp = rindex(name, '/');
+	cp = strrchr(name, '/');
 	if (cp == NULL || cp == name)
 		return(0);
 	*cp = '\0';
@@ -1055,7 +1053,7 @@
 static int
 fchog(int fd, char *file, char *owner, char *group, int mode)
 {
-	register int i;
+	int i;
 	int uid, gid;
 	extern char user[];
 	extern int userid;
@@ -1116,7 +1114,7 @@
 static void
 rmchk(int opts)
 {
-	register char *cp, *s;
+	char *cp, *s;
 	struct stat stb;
 
 	if (debug)
@@ -1160,7 +1158,7 @@
 		case '\0':
 			*--cp = '\0';
 			if (*s != '\0')
-				log(lfp, "%s\n", s);
+				dolog(lfp, "%s\n", s);
 			break;
 
 		case 'E':
@@ -1195,10 +1193,10 @@
  * for extraneous files and remove them.
  */
 static void
-clean(register char *cp)
+clean(char *cp)
 {
 	DIR *d;
-	register struct dirent *dp;
+	struct dirent *dp;
 	struct stat stb;
 	char *otp;
 	int len, opts;
@@ -1271,7 +1269,7 @@
 {
 	DIR *d;
 	struct dirent *dp;
-	register char *cp;
+	char *cp;
 	struct stat stb;
 	char *otp;
 	int len;
@@ -1338,7 +1336,7 @@
 dospecial(char *cmd)
 {
 	int fd[2], status, pid, i;
-	register char *cp, *s;
+	char *cp, *s;
 	char sbuf[BUFSIZ];
 	extern int userid, groupid;
 
@@ -1402,7 +1400,7 @@
 }
 
 void
-log(FILE *fp, const char *fmt, ...)
+dolog(FILE *fp, const char *fmt, ...)
 {
 	va_list ap;
 
@@ -1497,13 +1495,13 @@
 	case '\0':
 		*--cp = '\0';
 		if (*s != '\0') {
-			log(lfp, "%s\n", s);
+			dolog(lfp, "%s\n", s);
 			return(1);
 		}
 		return(0);
 	case '\3':
 		*--cp = '\0';
-		log(lfp, "Note: %s\n",s);
+		dolog(lfp, "Note: %s\n",s);
 		return(response());
 
 	default:
