From Christos: kill the last bits of sprintf(), and use regcomp/regexec

rather than re_comp/re_exec.  (I committed my sprintf sweep-up before
I realized that Christos had already done it...)
This commit is contained in:
thorpej 1996-07-12 00:38:50 +00:00
parent 336eeb5f1c
commit cf0afdf885
5 changed files with 25 additions and 24 deletions

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.11 (Berkeley) 3/12/91
# $Id: Makefile,v 1.3 1994/03/07 05:05:16 cgd Exp $
# $Id: Makefile,v 1.4 1996/07/12 00:38:50 thorpej Exp $
PROG= rdist
CFLAGS+=-I${.CURDIR}
@ -9,7 +9,4 @@ BINOWN= root
BINMODE=4555
CLEANFILES=y.tab.h
LDADD= -lcompat
DPADD= ${LIBCOMPAT}
.include <bsd.prog.mk>

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)defs.h 8.1 (Berkeley) 6/9/93
* $Id: defs.h,v 1.5 1994/03/07 05:05:20 cgd Exp $
* $Id: defs.h,v 1.6 1996/07/12 00:38:51 thorpej Exp $
*/
#include <sys/param.h>
@ -150,7 +150,7 @@ extern struct linkbuf *ihead; /* list of files with more than one link */
extern struct passwd *pw; /* pointer to static area used by getpwent */
extern struct group *gr; /* pointer to static area used by getgrent */
extern char host[]; /* host name of master copy */
extern char buf[]; /* general purpose buffer */
extern char buf[BUFSIZ]; /* general purpose buffer */
int any __P((int, char *));
char *colon __P((char *));

View File

@ -33,12 +33,13 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */
static char *rcsid = "$Id: docmd.c,v 1.7 1996/07/12 00:06:32 thorpej Exp $";
static char *rcsid = "$Id: docmd.c,v 1.8 1996/07/12 00:38:53 thorpej Exp $";
#endif /* not lint */
#include "defs.h"
#include <setjmp.h>
#include <netdb.h>
#include <regex.h>
FILE *lfp; /* log file for recording files updated */
struct subcmd *subcmds; /* list of sub-commands for current cmd */
@ -233,7 +234,7 @@ makeconn(rhost)
ruser = user;
if (!qflag)
printf("updating host %s\n", rhost);
(void) snprintf(buf, BUFSIZ, "%s -Server%s", _PATH_RDIST,
(void) snprintf(buf, sizeof(buf), "%s -Server%s", _PATH_RDIST,
qflag ? " -q" : "");
if (port < 0) {
struct servent *sp;
@ -531,7 +532,7 @@ notify(file, rhost, to, lmod)
/*
* Create a pipe to mailling program.
*/
(void)snprintf(buf, BUFSIZ, "%s -oi -t", _PATH_SENDMAIL);
(void)snprintf(buf, sizeof(buf), "%s -oi -t", _PATH_SENDMAIL);
pf = popen(buf, "w");
if (pf == NULL) {
error("notify: \"%s\" failed\n", _PATH_SENDMAIL);
@ -594,6 +595,8 @@ except(file)
{
register struct subcmd *sc;
register struct namelist *nl;
int err;
regex_t s;
if (debug)
printf("except(%s)\n", file);
@ -607,8 +610,12 @@ except(file)
return(1);
continue;
}
re_comp(nl->n_name);
if (re_exec(file) > 0)
if ((err = regcomp(&s, nl->n_name, 0)) != 0) {
char ebuf[BUFSIZ];
(void) regerror(err, &s, ebuf, sizeof(ebuf));
error("%s: %s\n", nl->n_name, ebuf);
}
if (regexec(&s, file, 0, NULL, 0) == 0)
return(1);
}
}

View File

@ -34,7 +34,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)gram.y 8.1 (Berkeley) 6/9/93"; */
static char *rcsid = "$Id: gram.y,v 1.3 1994/03/07 05:05:30 cgd Exp $";
static char *rcsid = "$Id: gram.y,v 1.4 1996/07/12 00:38:54 thorpej Exp $";
#endif /* not lint */
#include "defs.h"
@ -163,13 +163,8 @@ cmd: INSTALL options opt_namelist SM = {
$$ = $1;
}
| PATTERN namelist SM = {
struct namelist *nl;
char *cp, *re_comp();
for (nl = $2; nl != NULL; nl = nl->n_next)
if ((cp = re_comp(nl->n_name)) != NULL)
yyerror(cp);
$1->sc_args = expand($2, E_VARS);
if ($2 != NULL)
$1->sc_args = expand($2, E_VARS);
$$ = $1;
}
| SPECIAL opt_namelist STRING SM = {

View File

@ -33,7 +33,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; */
static char *rcsid = "$Id: server.c,v 1.9 1996/07/12 00:06:37 thorpej Exp $";
static char *rcsid = "$Id: server.c,v 1.10 1996/07/12 00:38:55 thorpej Exp $";
#endif /* not lint */
#include <sys/wait.h>
@ -661,7 +661,8 @@ query(name)
struct stat stb;
if (catname)
(void) sprintf(tp, "/%s", name);
(void) snprintf(tp, sizeof(target) - (tp - target),
"/%s", name);
if (lstat(target, &stb) < 0) {
if (errno == ENOENT)
@ -794,7 +795,7 @@ recvf(cmd, type)
}
if (catname)
(void) sprintf(tp, "/%s", cp);
(void) snprintf(tp, sizeof(target) - (tp - target), "/%s", cp);
cp = rindex(target, '/');
if (cp == NULL)
strcpy(new, tempname);
@ -973,7 +974,7 @@ hardlink(cmd)
*cp++ = '\0';
if (catname) {
(void) sprintf(tp, "/%s", cp);
(void) snprintf(tp, sizeof(target) - (tp - target), "/%s", cp);
}
if (lstat(target, &stb) == 0) {
int mode = stb.st_mode & S_IFMT;
@ -1130,7 +1131,8 @@ rmchk(opts)
* Y\n -- file doesn't exist - REMOVE.
*/
*--cp = '\0';
(void) sprintf(tp, "/%s", s);
(void) snprintf(tp, sizeof(target) - (tp - target),
"/%s", s);
if (debug)
printf("check %s\n", target);
if (except(target))