summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-16 10:43:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-16 10:43:02 +0000
commit09ee7c2c261c3af64d5de451da1a1dfa7b83f4bc (patch)
tree0cdf465f1b13e60170d7cef9e1f053334c247dfa /usr.bin
parentc252fccfc8555d969e33811d7fcf73db47d82a04 (diff)
snprintf this thing
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sup/src/ci.c6
-rw-r--r--usr.bin/sup/src/scan.c30
-rw-r--r--usr.bin/sup/src/supcmain.c22
-rw-r--r--usr.bin/sup/src/supcmeat.c48
-rw-r--r--usr.bin/sup/src/supcmisc.c10
-rw-r--r--usr.bin/sup/src/supcname.c4
-rw-r--r--usr.bin/sup/src/supcparse.c4
-rw-r--r--usr.bin/sup/src/supfilesrv.c49
-rw-r--r--usr.bin/sup/src/supscan.c11
9 files changed, 105 insertions, 79 deletions
diff --git a/usr.bin/sup/src/ci.c b/usr.bin/sup/src/ci.c
index 12100239cae..bf40de016e7 100644
--- a/usr.bin/sup/src/ci.c
+++ b/usr.bin/sup/src/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.4 1997/08/18 03:11:29 millert Exp $ */
+/* $OpenBSD: ci.c,v 1.5 1997/09/16 10:42:49 deraadt Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@@ -249,7 +249,7 @@ char *cmdfpath; /* search list for command files */
if (*cinext) { /* get line from ^ command */
if (ciback) {
- sprintf(line,"%s;%s",cinext,ciprev);
+ snprintf(line,sizeof line,"%s;%s",cinext,ciprev);
ciback = 0;
}
else {
@@ -452,7 +452,7 @@ char *cmdfpath; /* search list for command files */
i = getstab ("INTERRUPT: abort or breakpoint?",delchoice,"abort");
if (i == 0) ciexit = 1; /* abort */
else { /* breakpoint */
- sprintf (bprompt,"Breakpoint for %s",prompt);
+ snprintf (bprompt,sizeof bprompt,"Breakpoint for %s",prompt);
ci (bprompt,0,cidepth,list,helppath,cmdfpath);
}
}
diff --git a/usr.bin/sup/src/scan.c b/usr.bin/sup/src/scan.c
index 6e64bd47c26..5ae3dbe57a0 100644
--- a/usr.bin/sup/src/scan.c
+++ b/usr.bin/sup/src/scan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scan.c,v 1.6 1997/04/01 07:35:20 todd Exp $ */
+/* $OpenBSD: scan.c,v 1.7 1997/09/16 10:42:51 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -283,7 +283,7 @@ char *release;
release = salloc (DEFRELEASE);
listTL = NULL;
- (void) sprintf (buf,FILERELEASES,collname);
+ (void) snprintf (buf,sizeof buf,FILERELEASES,collname);
f = fopen (buf,"r");
if (f != NULL) {
rewound = TRUE;
@@ -338,7 +338,7 @@ makescanlists ()
char *saveprefix = prefix;
int count = 0;
- (void) sprintf (buf,FILERELEASES,collname);
+ (void) snprintf (buf,sizeof buf,FILERELEASES,collname);
f = fopen (buf,"r");
if (f != NULL) {
while ((p = fgets (buf,sizeof(buf),f)) != NULL) {
@@ -439,7 +439,7 @@ doscan (listfile)
rsymT = NULL;
if (listfile == NULL)
listfile = FILELISTDEF;
- (void) sprintf (buf,FILELIST,collname,listfile);
+ (void) snprintf (buf,sizeof buf,FILELIST,collname,listfile);
readlistfile (buf); /* get contents of list file */
(void) Tprocess (upgT,listone, NULL); /* build list of files specified */
cdprefix ((char *)NULL);
@@ -565,7 +565,7 @@ char *exec;
newt = Tinsert (t,speclist[i],TRUE);
newt->Tflags |= flags;
if (exec) {
- (void) sprintf (buf,exec,speclist[i]);
+ (void) snprintf (buf,sizeof buf,exec,speclist[i]);
(void) Tinsert (&newt->Texec,buf,FALSE);
}
free (speclist[i]);
@@ -633,14 +633,16 @@ int always;
int status;
if (rcs_branch != NULL)
#ifdef CVS
- sprintf(rcs_release, "-r %s", rcs_branch);
+ snprintf(rcs_release,sizeof rcs_release,
+ "-r %s", rcs_branch);
#else
- sprintf(rcs_release, "-r%s", rcs_branch);
+ snprintf(rcs_release,sizeof rcs_release,
+ "-r%s", rcs_branch);
#endif
else
rcs_release[0] = '\0';
#ifdef CVS
- sprintf(sys_com, "cvs -d %s -r -l -Q co -p %s %s > %s\n", cvs_root, rcs_release, name, rcs_file);
+ snprintf(sys_com, sizeof sys_com, "cvs -d %s -r -l -Q co -p %s %s > %s\n", cvs_root, rcs_release, name, rcs_file);
#else
status = runp("rcsstat", "rcsstat", "-q", rcs_release, name, 0);
#endif
@@ -718,7 +720,7 @@ int always;
ename[i] = dentry->d_name[i];
ename[i] = 0;
if (*newname)
- (void) sprintf (filename,"%s/%s",newname,ename);
+ (void) snprintf (filename,sizeof filename,"%s/%s",newname,ename);
else
(void) strcpy (filename,ename);
listentry(ename,filename,newname,always);
@@ -820,7 +822,7 @@ char *scanfile;
if (scanfile == NULL)
scanfile = FILESCANDEF;
- (void) sprintf (buf,FILESCAN,collname,scanfile);
+ (void) snprintf (buf,sizeof buf,FILESCAN,collname,scanfile);
if (stat(buf,&sbuf) < 0)
return (FALSE);
if ((f = fopen (buf,"r")) == NULL)
@@ -915,8 +917,8 @@ char *scanfile;
if (scanfile == NULL)
scanfile = FILESCANDEF;
- (void) sprintf (fname,FILESCAN,collname,scanfile);
- (void) sprintf (tname,"%s.temp",fname);
+ (void) snprintf (fname,sizeof fname,FILESCAN,collname,scanfile);
+ (void) snprintf (tname,sizeof tname,"%s.temp",fname);
if (NULL == (f = fopen (tname, "w")))
goaway ("Can't test scan file temp %s for %s",tname,collname);
else {
@@ -934,8 +936,8 @@ char *scanfile;
if (scanfile == NULL)
scanfile = FILESCANDEF;
- (void) sprintf (fname,FILESCAN,collname,scanfile);
- (void) sprintf (tname,"%s.temp",fname);
+ (void) snprintf (fname,sizeof fname,FILESCAN,collname,scanfile);
+ (void) snprintf (tname,sizeof tname,"%s.temp",fname);
scanF = fopen (tname,"w");
if (scanF == NULL)
goaway ("Can't write scan file temp %s for %s",tname,collname);
diff --git a/usr.bin/sup/src/supcmain.c b/usr.bin/sup/src/supcmain.c
index 8a9b9fc9a7e..9c5009cd1fa 100644
--- a/usr.bin/sup/src/supcmain.c
+++ b/usr.bin/sup/src/supcmain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcmain.c,v 1.5 1997/04/01 07:35:32 todd Exp $ */
+/* $OpenBSD: supcmain.c,v 1.6 1997/09/16 10:42:52 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -603,11 +603,12 @@ char **argv;
rpauseflag = TRUE;
(void) signal (SIGSYS,oldsigsys);
#endif /* MACH */
- if (sysflag)
- (void) sprintf (supfname = buf,
- timeflag?FILESUPTDEFAULT:FILESUPDEFAULT,
- DEFDIR);
- else {
+ if (sysflag) {
+ (void) snprintf (buf,sizeof buf,
+ timeflag?FILESUPTDEFAULT:FILESUPDEFAULT,
+ DEFDIR);
+ supfname = buf;
+ } else {
supfname = argv[1];
if (strcmp (supfname,"-") == 0)
supfname = "";
@@ -672,7 +673,8 @@ char **argv;
c->Cnotify = salloc (username);
}
if (c->Cbase == NULL) {
- (void) sprintf (buf,FILEBASEDEFAULT,c->Cname);
+ (void) snprintf (buf,sizeof buf,
+ FILEBASEDEFAULT,c->Cname);
c->Cbase = salloc (buf);
}
}
@@ -686,8 +688,10 @@ char **argv;
p = "standard input";
else if (sysflag)
p = "system software";
- else
- (void) sprintf (p = buf,"file %s",supfname);
+ else {
+ (void) snprintf (buf,sizeof buf,"file %s",supfname);
+ p = buf;
+ }
if (!silent)
loginfo ("SUP %d.%d (%s) for %s at %s",PROTOVERSION,PGMVERSION,
scmversion,p,fmttime (timenow));
diff --git a/usr.bin/sup/src/supcmeat.c b/usr.bin/sup/src/supcmeat.c
index 8701fec5f43..eae71b0c8f8 100644
--- a/usr.bin/sup/src/supcmeat.c
+++ b/usr.bin/sup/src/supcmeat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcmeat.c,v 1.6 1997/07/28 09:47:38 deraadt Exp $ */
+/* $OpenBSD: supcmeat.c,v 1.7 1997/09/16 10:42:54 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -272,7 +272,8 @@ register TREE *t;
/* read time of last upgrade from when file */
if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) sprintf (relsufix,".%s",thisC->Crelease);
+ (void) snprintf (relsufix,sizeof relsufix,
+ ".%s",thisC->Crelease);
else
relsufix[0] = '\0';
lasttime = getwhen(collname,relsufix);
@@ -342,7 +343,7 @@ void login (void)
register int f,x;
/* lock collection if desired */
- (void) sprintf (buf,FILELOCK,collname);
+ (void) snprintf (buf,sizeof buf,FILELOCK,collname);
f = open (buf,O_RDONLY,0);
if (f >= 0) {
@@ -430,10 +431,10 @@ void listfiles ()
if ((thisC->Cflags&CFURELSUF) && release)
- (void) sprintf (relsufix,".%s",release);
+ (void) snprintf (relsufix,sizeof relsufix,".%s",release);
else
relsufix[0] = '\0';
- (void) sprintf (buf,FILELAST,collname,relsufix);
+ (void) snprintf (buf,sizeof buf,FILELAST,collname,relsufix);
f = fopen (buf,"r");
if (f) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
@@ -444,7 +445,7 @@ void listfiles ()
(void) fclose (f);
}
refuseT = NULL;
- (void) sprintf (buf,FILEREFUSE,collname);
+ (void) snprintf (buf,sizeof buf,FILEREFUSE,collname);
f = fopen (buf,"r");
if (f) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
@@ -919,10 +920,11 @@ register struct stat *statp;
return (TRUE); /* mark upgrade as nogood */
}
path (t->Tname,dirpart,filepart);
- (void) sprintf (filename,FILEBACKUP,dirpart,filepart);
+ (void) snprintf (filename,sizeof filename,
+ FILEBACKUP,dirpart,filepart);
fout = fopen (filename,"w");
if (fout == NULL) {
- (void) sprintf (buf,FILEBKDIR,dirpart);
+ (void) snprintf (buf,sizeof buf,FILEBKDIR,dirpart);
(void) mkdir (buf,0755);
fout = fopen (filename,"w");
}
@@ -1059,35 +1061,41 @@ char *from; /* 0 if reading from network */
for (;;) {
/* try destination directory */
path (to,dpart,fpart);
- (void) sprintf (tname,"%s/#%d.sup",dpart,thispid);
+ (void) snprintf (tname,sizeof tname,
+ "%s/#%d.sup",dpart,thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) break;
/* try sup directory */
if (thisC->Cprefix) (void) chdir (thisC->Cbase);
- (void) sprintf (tname,"sup/#%d.sup",thispid);
+ (void) snprintf (tname,sizeof tname,
+ "sup/#%d.sup",thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) {
if (thisC->Cprefix) (void) chdir (thisC->Cprefix);
break;
}
/* try base directory */
- (void) sprintf (tname,"#%d.sup",thispid);
+ (void) snprintf (tname,sizeof tname,
+ "#%d.sup",thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (thisC->Cprefix) (void) chdir (thisC->Cprefix);
if (tof >= 0) break;
#ifdef VAR_TMP
/* try /var/tmp */
- (void) sprintf (tname,"/var/tmp/#%d.sup",thispid);
+ (void) snprintf (tname,sizeof tname,
+ "/var/tmp/#%d.sup",thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) break;
#else
/* try /usr/tmp */
- (void) sprintf (tname,"/usr/tmp/#%d.sup",thispid);
+ (void) snprintf (tname,sizeof tname,
+ "/usr/tmp/#%d.sup",thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) break;
#endif
/* try /tmp */
- (void) sprintf (tname,"/tmp/#%d.sup",thispid);
+ (void) snprintf (tname,sizeof tname,
+ "/tmp/#%d.sup",thispid);
tof = open (tname,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) break;
istemp = FALSE;
@@ -1241,8 +1249,10 @@ int x;
FILE *finishfile; /* record of all filenames */
if ((thisC->Cflags&CFURELSUF) && release) {
- (void) sprintf (relsufix,".%s",release);
- (void) sprintf (collrelname,"%s-%s",collname,release);
+ (void) snprintf (relsufix,sizeof relsufix,
+ ".%s",release);
+ (void) snprintf (collrelname,sizeof collrelname,
+ "%s-%s",collname,release);
} else {
relsufix[0] = '\0';
(void) strcpy (collrelname,collname);
@@ -1287,7 +1297,7 @@ int x;
(void) requestend ();
return;
}
- (void) sprintf (fname,FILEWHEN,collname,relsufix);
+ (void) snprintf (fname,sizeof fname,FILEWHEN,collname,relsufix);
if (establishdir (fname)) {
notify ("SUP: Can't create directory for upgrade timestamp\n");
Tfree (&lastT);
@@ -1311,7 +1321,7 @@ int x;
done (FDONESUCCESS,"Success");
(void) requestend ();
}
- (void) sprintf (tname,FILELASTTEMP,collname,relsufix);
+ (void) snprintf (tname,sizeof tname,FILELASTTEMP,collname,relsufix);
finishfile = fopen (tname,"w");
if (finishfile == NULL) {
notify ("SUP: Can't record list of all files in %s\n",tname);
@@ -1320,7 +1330,7 @@ int x;
}
(void) Tprocess (lastT,finishone,finishfile);
(void) fclose (finishfile);
- (void) sprintf (fname,FILELAST,collname,relsufix);
+ (void) snprintf (fname,sizeof fname,FILELAST,collname,relsufix);
if (rename (tname,fname) < 0)
notify ("SUP: Can't change %s to %s\n",tname,fname);
(void) unlink (tname);
diff --git a/usr.bin/sup/src/supcmisc.c b/usr.bin/sup/src/supcmisc.c
index 140f8fdb743..cc4e962a126 100644
--- a/usr.bin/sup/src/supcmisc.c
+++ b/usr.bin/sup/src/supcmisc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcmisc.c,v 1.4 1997/04/01 07:35:35 todd Exp $ */
+/* $OpenBSD: supcmisc.c,v 1.5 1997/09/16 10:42:55 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -75,7 +75,7 @@ prtime ()
time_t twhen;
if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) sprintf (relsufix,".%s",thisC->Crelease);
+ (void) snprintf (relsufix,sizeof relsufix,".%s",thisC->Crelease);
else
relsufix[0] = '\0';
if (chdir (thisC->Cbase) < 0)
@@ -260,13 +260,15 @@ va_dcl
return;
}
if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) sprintf (collrelname,"%s-%s",collname,thisC->Crelease);
+ (void) snprintf (collrelname,sizeof collrelname,
+ "%s-%s",collname,thisC->Crelease);
else
(void) strcpy (collrelname,collname);
if (noteF == NULL) {
if ((thisC->Cflags&CFMAIL) && thisC->Cnotify) {
- (void) sprintf (buf,"mail -s \"SUP Upgrade of %s\" %s >/dev/null",
+ (void) snprintf (buf,sizeof buf,
+ "mail -s \"SUP Upgrade of %s\" %s >/dev/null",
collrelname,thisC->Cnotify);
noteF = popen (buf,"w");
if (noteF == NULL) {
diff --git a/usr.bin/sup/src/supcname.c b/usr.bin/sup/src/supcname.c
index a4ddfc5a342..3e323e15a1c 100644
--- a/usr.bin/sup/src/supcname.c
+++ b/usr.bin/sup/src/supcname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcname.c,v 1.4 1997/04/01 07:35:36 todd Exp $ */
+/* $OpenBSD: supcname.c,v 1.5 1997/09/16 10:42:56 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -72,7 +72,7 @@ void getnams ()
for (c = firstC; c && c->Chtree != NULL; c = c->Cnext);
if (c == NULL) return;
- (void) sprintf (buf,FILEHOSTS,DEFDIR);
+ (void) snprintf (buf,sizeof buf,FILEHOSTS,DEFDIR);
f = fopen (buf,"r");
if (f == NULL) logquit (1,"Can't open %s",buf);
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
diff --git a/usr.bin/sup/src/supcparse.c b/usr.bin/sup/src/supcparse.c
index fb9b4a4c28a..f5d76a3e31e 100644
--- a/usr.bin/sup/src/supcparse.c
+++ b/usr.bin/sup/src/supcparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcparse.c,v 1.3 1997/04/01 07:35:38 todd Exp $ */
+/* $OpenBSD: supcparse.c,v 1.4 1997/09/16 10:42:57 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -224,7 +224,7 @@ getwhen(collection, relsuffix)
FILE *fp;
time_t tstamp;
- (void) sprintf (buf,FILEWHEN,collection,relsuffix);
+ (void) snprintf (buf,sizeof buf,FILEWHEN,collection,relsuffix);
if ((fp = fopen(buf, "r")) == NULL)
return 0;
diff --git a/usr.bin/sup/src/supfilesrv.c b/usr.bin/sup/src/supfilesrv.c
index e9cb14dbc36..3676d7e071a 100644
--- a/usr.bin/sup/src/supfilesrv.c
+++ b/usr.bin/sup/src/supfilesrv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supfilesrv.c,v 1.9 1997/09/08 23:59:43 millert Exp $ */
+/* $OpenBSD: supfilesrv.c,v 1.10 1997/09/16 10:42:59 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -683,7 +683,7 @@ srvsetup ()
/* check crosspatch host access file */
cryptkey = NULL;
- (void) sprintf (buf,FILEXPATCH,xuser);
+ (void) snprintf (buf,sizeof buf,FILEXPATCH,xuser);
/* Turn off link following */
if (link_nofollow(1) != -1) {
@@ -745,7 +745,7 @@ srvsetup ()
release = salloc (DEFRELEASE);
if (basedir == NULL || *basedir == '\0') {
basedir = NULL;
- (void) sprintf (buf,FILEDIRS,DEFDIR);
+ (void) snprintf (buf,sizeof buf,FILEDIRS,DEFDIR);
f = fopen (buf,"r");
if (f) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
@@ -762,13 +762,13 @@ srvsetup ()
(void) fclose (f);
}
if (basedir == NULL) {
- (void) sprintf (buf,FILEBASEDEFAULT,collname);
+ (void) snprintf (buf,sizeof buf,FILEBASEDEFAULT,collname);
basedir = salloc(buf);
}
}
if (chdir (basedir) < 0)
goaway ("Can't chdir to base directory %s",basedir);
- (void) sprintf (buf,FILEPREFIX,collname);
+ (void) snprintf (buf,sizeof buf,FILEPREFIX,collname);
f = fopen (buf,"r");
if (f) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
@@ -812,7 +812,7 @@ srvsetup ()
char *h;
if ((h = tl->TLhost) == NULL)
h = FILEHOSTDEF;
- (void) sprintf (buf,FILEHOST,collname,h);
+ (void) snprintf (buf,sizeof buf,FILEHOST,collname,h);
f = fopen (buf,"r");
if (f) {
int hostok = FALSE;
@@ -842,7 +842,7 @@ srvsetup ()
}
}
/* try to lock collection */
- (void) sprintf (buf,FILELOCK,collname);
+ (void) snprintf (buf,sizeof buf,FILELOCK,collname);
#ifdef LOCK_SH
x = open (buf,O_RDONLY,0);
if (x >= 0) {
@@ -874,7 +874,7 @@ docrypt ()
struct stat sbuf;
if (!xpatch) {
- (void) sprintf (buf,FILECRYPT,collname);
+ (void) snprintf (buf,sizeof buf,FILECRYPT,collname);
/* Turn off link following */
if (link_nofollow(1) != -1) {
@@ -1151,8 +1151,9 @@ void *v;
av[ac++] = "-q";
av[ac++] = "-p";
if (rcs_branch != NULL) {
- sprintf(rcs_release, "-r%s",
- rcs_branch);
+ snprintf(rcs_release,
+ sizeof rcs_release,
+ "-r%s",rcs_branch);
av[ac++] = rcs_release;
}
#endif
@@ -1314,20 +1315,21 @@ time_t starttime;
logerr ("Reason %d: %s",doneack,donereason);
goawayreason = donereason;
cdprefix ((char *)NULL);
- (void) sprintf (lognam,FILELOGFILE,collname);
+ (void) snprintf (lognam,sizeof lognam,FILELOGFILE,collname);
if ((logfd = open(lognam,O_APPEND|O_WRONLY,0644)) < 0)
return; /* can not open file up...error */
finishtime = time ((time_t *)NULL);
p = tmpbuf;
- (void) sprintf (p,"%s ",fmttime (lasttime));
+ (void) snprintf (p,sizeof tmpbuf-(p-tmpbuf),"%s ",fmttime (lasttime));
p += strlen(p);
- (void) sprintf (p,"%s ",fmttime (starttime));
+ (void) snprintf (p,sizeof tmpbuf-(p-tmpbuf),"%s ",fmttime (starttime));
p += strlen(p);
- (void) sprintf (p,"%s ",fmttime (finishtime));
+ (void) snprintf (p,sizeof tmpbuf-(p-tmpbuf),"%s ",fmttime (finishtime));
p += strlen(p);
if ((releasename = release) == NULL)
releasename = "UNKNOWN";
- (void) sprintf (p,"%s %s %d %s\n",remotehost(),releasename,
+ (void) snprintf (p,sizeof tmpbuf-(p-tmpbuf),"%s %s %d %s\n",
+ remotehost(),releasename,
FDONESUCCESS-doneack,donereason);
p += strlen(p);
#if MACH
@@ -1456,7 +1458,8 @@ int fileuid,filegid;
if (namep == NULL) {
pwd = getpwuid (fileuid);
if (pwd == NULL) {
- (void) sprintf (errbuf,"Reason: Unknown user id %d",
+ (void) snprintf (errbuf,sizeof errbuf,
+ "Reason: Unknown user id %d",
fileuid);
return (errbuf);
}
@@ -1479,7 +1482,8 @@ int fileuid,filegid;
}
pwd = getpwnam (nbuf);
if (pwd == NULL) {
- (void) sprintf (errbuf,"Reason: Unknown user %s",
+ (void) snprintf (errbuf,sizeof errbuf,
+ "Reason: Unknown user %s",
nbuf);
return (errbuf);
}
@@ -1493,8 +1497,9 @@ int fileuid,filegid;
setpag(); /* set a pag */
if (ka_UserAuthenticate(pwd->pw_name, "", 0,
pswdp, 1, &reason)) {
- (void) sprintf (errbuf,"AFS authentication failed, %s",
- reason);
+ (void) snprintf (errbuf,sizeof errbuf,
+ "AFS authentication failed, %s",
+ reason);
logerr ("Attempt by %s; %s",
nbuf, errbuf);
return (errbuf);
@@ -1538,7 +1543,7 @@ int fileuid,filegid;
break;
#if CMUCS
case ACCESS_CODE_INSECUREPWD:
- (void) sprintf (errbuf,"Reason: %s",p);
+ (void) snprintf (errbuf,sizeof errbuf,"Reason: %s",p);
p = errbuf;
break;
case ACCESS_CODE_DENIED:
@@ -1579,7 +1584,9 @@ int fileuid,filegid;
break;
#endif /* CMUCS */
default:
- (void) sprintf (p = errbuf,"Reason: Status %d",status);
+ (void) snprintf (errbuf,sizeof errbuf,
+ "Reason: Status %d",status);
+ p = errbuf;
break;
}
if (pwd == NULL)
diff --git a/usr.bin/sup/src/supscan.c b/usr.bin/sup/src/supscan.c
index 710a50ee9a4..19afba97438 100644
--- a/usr.bin/sup/src/supscan.c
+++ b/usr.bin/sup/src/supscan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supscan.c,v 1.6 1997/07/25 21:05:43 mickey Exp $ */
+/* $OpenBSD: supscan.c,v 1.7 1997/09/16 10:43:01 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -228,7 +228,7 @@ char **argv;
argv++;
}
if (!fflag) {
- (void) sprintf (fbuf,FILEDIRS,DEFDIR);
+ (void) snprintf (fbuf,sizeof fbuf,FILEDIRS,DEFDIR);
filename = fbuf;
}
if (sflag) {
@@ -236,7 +236,7 @@ char **argv;
usage ();
firstC = NULL;
c = &firstC;
- (void) sprintf (buf,FILEHOSTS,DEFDIR);
+ (void) snprintf (buf,sizeof buf,sizeof buf,FILEHOSTS,DEFDIR);
if ((f = fopen (buf,"r")) == NULL)
quit (1,"supscan: Unable to open %s\n",buf);
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
@@ -300,7 +300,8 @@ register char *filename,*collname,*basedir;
(void) fclose (f);
}
if (basedir == NULL) {
- (void) sprintf (buf,FILEBASEDEFAULT,collname);
+ (void) snprintf (buf,sizeof buf,sizeof buf,
+ FILEBASEDEFAULT,collname);
basedir = salloc (buf);
}
}
@@ -310,7 +311,7 @@ register char *filename,*collname,*basedir;
return (NULL);
}
prefix = NULL;
- (void) sprintf (buf,FILEPREFIX,collname);
+ (void) snprintf (buf,sizeof buf,FILEPREFIX,collname);
if ((f = fopen (buf,"r")) != NULL) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = strchr (p,'\n');