Index: usr.sbin/sup/source/scan.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/scan.c,v retrieving revision 1.32 diff -p -u -r1.32 scan.c --- usr.sbin/sup/source/scan.c 12 Mar 2016 02:26:40 -0000 1.32 +++ usr.sbin/sup/source/scan.c 4 Oct 2019 11:58:37 -0000 @@ -279,7 +279,7 @@ getrelease(char *release) frelease = release = estrdup(DEFRELEASE); listTL = NULL; - (void) sprintf(buf, FILERELEASES, collname); + snprintf(buf, sizeof buf, FILERELEASES, collname); f = fopen(buf, "r"); if (f != NULL) { rewound = TRUE; @@ -350,7 +350,7 @@ makescanlists(void) char *saveprefix = prefix; int count = 0; - (void) sprintf(buf, FILERELEASES, collname); + snprintf(buf, sizeof buf, FILERELEASES, collname); f = fopen(buf, "r"); if (f != NULL) { while ((p = fgets(buf, sizeof(buf), f)) != NULL) { @@ -451,7 +451,7 @@ doscan(char *listfile) rsymT = NULL; if (listfile == NULL) listfile = FILELISTDEF; - (void) sprintf(buf, FILELIST, collname, listfile); + snprintf(buf, sizeof buf, FILELIST, collname, listfile); readlistfile(buf); /* get contents of list file */ (void) Tprocess(upgT, listone, NULL); /* build list of files * specified */ @@ -577,7 +577,7 @@ expTinsert(char *p, TREE ** t, int flags newt = Tinsert(t, speclist[i], TRUE); newt->Tflags |= flags; if (exec) { - (void) sprintf(buf, exec, speclist[i]); + snprintf(buf, sizeof buf, exec, speclist[i]); (void) Tinsert(&newt->Texec, buf, FALSE); } free(speclist[i]); @@ -724,7 +724,7 @@ listdir(char *name, int always) if (strcmp(dentry->d_name, "..") == 0) continue; if (*newname) { - (void)snprintf(filename, sizeof(filename), "%s/%s", + snprintf(filename, sizeof(filename), "%s/%s", newname, dentry->d_name); } else { (void)strncpy(filename, dentry->d_name, @@ -829,7 +829,7 @@ getscanfile(char *scanfile) if (scanfile == NULL) scanfile = FILESCANDEF; - (void) sprintf(buf, FILESCAN, collname, scanfile); + snprintf(buf, sizeof buf, FILESCAN, collname, scanfile); if (stat(buf, &sbuf) < 0) return (FALSE); if ((f = fopen(buf, "r")) == NULL) @@ -930,8 +930,8 @@ chkscanfile(char *scanfile) if (scanfile == NULL) scanfile = FILESCANDEF; - (void) sprintf(fname, FILESCAN, collname, scanfile); - (void) sprintf(tname, "%s.temp", fname); + snprintf(fname, sizeof fname, FILESCAN, collname, scanfile); + 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 { @@ -949,8 +949,8 @@ makescanfile(char *scanfile) if (scanfile == NULL) scanfile = FILESCANDEF; - (void) sprintf(fname, FILESCAN, collname, scanfile); - (void) sprintf(tname, "%s.temp", fname); + snprintf(fname, sizeof fname, FILESCAN, collname, scanfile); + snprintf(tname, sizeof tname, "%s.temp", fname); scanF = fopen(tname, "w"); if (scanF == NULL) goto out; Index: usr.sbin/sup/source/supcmain.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supcmain.c,v retrieving revision 1.34 diff -p -u -r1.34 supcmain.c --- usr.sbin/sup/source/supcmain.c 4 May 2017 16:26:10 -0000 1.34 +++ usr.sbin/sup/source/supcmain.c 4 Oct 2019 11:58:37 -0000 @@ -718,7 +718,7 @@ init(int argc, char **argv) c->Cnotify = estrdup(username); } if (c->Cbase == NULL) { - (void) sprintf(buf, FILEBASEDEFAULT, c->Cname); + snprintf(buf, sizeof buf, FILEBASEDEFAULT, c->Cname); c->Cbase = estrdup(buf); } } @@ -737,7 +737,7 @@ init(int argc, char **argv) else if (sysflag) p = "system software"; else - (void) sprintf(p = buf, "file %s", supfname); + snprintf(p = buf, sizeof buf, "file %s", supfname); if (!silent) loginfo("SUP %d.%d (%s) for %s at %s", PROTOVERSION, PGMVERSION, scmversion, p, fmttime(timenow)); Index: usr.sbin/sup/source/supcmisc.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supcmisc.c,v retrieving revision 1.23 diff -p -u -r1.23 supcmisc.c --- usr.sbin/sup/source/supcmisc.c 8 Mar 2013 20:56:44 -0000 1.23 +++ usr.sbin/sup/source/supcmisc.c 4 Oct 2019 11:58:37 -0000 @@ -85,15 +85,15 @@ prtime(void) time_t twhen; if ((thisC->Cflags & CFURELSUF) && thisC->Crelease) - (void) sprintf(relsufix, ".%s", thisC->Crelease); + snprintf(relsufix, sizeof relsufix, ".%s", thisC->Crelease); else relsufix[0] = '\0'; if (chdir(thisC->Cbase) < 0) logerr("Can't change to base directory %s for collection %s", thisC->Cbase, thisC->Cname); twhen = getwhen(thisC->Cname, relsufix); - (void) strcpy(buf, ctime(&twhen)); - buf[strlen(buf) - 1] = '\0'; + strncpy(buf, ctime(&twhen), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; loginfo("Last update occurred at %s for collection %s%s", buf, thisC->Cname, relsufix); } @@ -282,9 +282,10 @@ notify(int f, const char *fmt, ...) va_start(ap, fmt); if ((thisC->Cflags & CFURELSUF) && thisC->Crelease) - (void) sprintf(collrelname, "%s-%s", collname, thisC->Crelease); + snprintf(collrelname, sizeof collrelname, "%s-%s", collname, + thisC->Crelease); else - (void) strcpy(collrelname, collname); + strcpy(collrelname, collname); if (fmt == NULL) { if (noteF && noteF != stdout && (!silent || thisC->Cnogood)) { Index: usr.sbin/sup/source/supcname.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supcname.c,v retrieving revision 1.7 diff -p -u -r1.7 supcname.c --- usr.sbin/sup/source/supcname.c 17 Oct 2009 20:46:03 -0000 1.7 +++ usr.sbin/sup/source/supcname.c 4 Oct 2019 11:58:37 -0000 @@ -77,7 +77,7 @@ getnams(void) for (c = firstC; c && c->Chtree != NULL; c = c->Cnext); if (c == NULL) return; - (void) sprintf(buf, FILEHOSTS, DEFDIR); + snprintf(buf, sizeof buf, FILEHOSTS, DEFDIR); f = fopen(buf, "r"); if (f == NULL) logquit(1, "Can't open %s", buf); Index: usr.sbin/sup/source/supcparse.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supcparse.c,v retrieving revision 1.16 diff -p -u -r1.16 supcparse.c --- usr.sbin/sup/source/supcparse.c 9 Apr 2013 16:39:20 -0000 1.16 +++ usr.sbin/sup/source/supcparse.c 4 Oct 2019 11:58:37 -0000 @@ -242,7 +242,7 @@ getwhen(char *collection, char *relsuffi FILE *fp; time_t tstamp; - (void) sprintf(buf, FILEWHEN, collection, relsuffix); + snprintf(buf, sizeof buf, FILEWHEN, collection, relsuffix); if ((fp = fopen(buf, "r")) == NULL) return 0; Index: usr.sbin/sup/source/supfilesrv.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supfilesrv.c,v retrieving revision 1.52 diff -p -u -r1.52 supfilesrv.c --- usr.sbin/sup/source/supfilesrv.c 3 Feb 2019 03:19:31 -0000 1.52 +++ usr.sbin/sup/source/supfilesrv.c 4 Oct 2019 11:58:37 -0000 @@ -889,7 +889,7 @@ srvsetup(void) /* check crosspatch host access file */ cryptkey = NULL; - (void) sprintf(buf, FILEXPATCH, xuser); + snprintf(buf, sizeof buf, FILEXPATCH, xuser); /* Turn off link following */ if (link_nofollow(1) != -1) { @@ -955,7 +955,7 @@ srvsetup(void) release = estrdup(DEFRELEASE); if (basedir == NULL || *basedir == '\0') { basedir = NULL; - (void) sprintf(filename, FILEDIRS, DEFDIR); + snprintf(filename, sizeof filename, FILEDIRS, DEFDIR); f = fopen(filename, "r"); if (f) { while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) { @@ -974,14 +974,14 @@ srvsetup(void) (void) fclose(f); } if (basedir == NULL) { - (void) sprintf(buf, FILEBASEDEFAULT, collname); + snprintf(buf, sizeof buf, FILEBASEDEFAULT, collname); basedir = estrdup(buf); } } if (chdir(basedir) < 0) goaway("Can't chdir to base directory %s (%s)", basedir, strerror(errno)); - (void) sprintf(filename, FILEPREFIX, collname); + snprintf(filename, sizeof filename, FILEPREFIX, collname); f = fopen(filename, "r"); if (f) { while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) { @@ -1038,7 +1038,7 @@ srvsetup(void) char *h; if ((h = tl->TLhost) == NULL) h = FILEHOSTDEF; - (void) sprintf(buf, FILEHOST, collname, h); + snprintf(buf, sizeof buf, FILEHOST, collname, h); f = fopen(buf, "r"); if (f) { int hostok = FALSE; @@ -1073,7 +1073,7 @@ srvsetup(void) } } /* try to lock collection */ - (void) sprintf(buf, FILELOCK, collname); + snprintf(buf, sizeof buf, FILELOCK, collname); #ifdef LOCK_SH x = open(buf, O_RDONLY, 0); if (x >= 0) { @@ -1107,7 +1107,7 @@ docrypt(void) struct stat sbuf; if (!xpatch) { - (void) sprintf(buf, FILECRYPT, collname); + snprintf(buf, sizeof buf, FILECRYPT, collname); /* Turn off link following */ if (link_nofollow(1) != -1) { @@ -1393,7 +1393,8 @@ send_one(TREE * t, void *v __unused) av[ac++] = "-q"; av[ac++] = "-p"; if (rcs_branch != NULL) { - sprintf(rcs_release, "-r%s", + snprintf(rcs_release, + sizeof rcs_release, "-r%s", rcs_branch); av[ac++] = rcs_release; } @@ -1561,7 +1562,7 @@ srvfinishup(time_t starttime) logerr("%s: NULL collection in svrfinishup", remotehost()); return; } - (void) sprintf(lognam, FILELOGFILE, collname); + 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(NULL); @@ -1703,9 +1704,9 @@ changeuid(char *namep, char *passwordp, if (namep == NULL) { pwd = getpwuid(fileuid); if (pwd == NULL) { - (void) sprintf(errbuf, "Reason: Unknown user id %d", - fileuid); - return (errbuf); + snprintf(errbuf, sizeof errbuf, + "Reason: Unknown user id %d", fileuid); + return errbuf; } grp = getgrgid(filegid); if (grp) @@ -1730,9 +1731,9 @@ changeuid(char *namep, char *passwordp, } pwd = getpwnam(nbuf); if (pwd == NULL) { - (void) sprintf(errbuf, "Reason: Unknown user %s", - nbuf); - return (errbuf); + snprintf(errbuf, sizeof errbuf, + "Reason: Unknown user %s", nbuf); + return errbuf; } if (strcmp(nbuf, DEFUSER) == 0) pswdp = NULL; @@ -1744,11 +1745,11 @@ changeuid(char *namep, char *passwordp, setpag(); /* set a pag */ if (ka_UserAuthenticate(pwd->pw_name, "", 0, pswdp, 1, &reason)) { - (void) sprintf(errbuf, "AFS authentication failed, %s", - reason); + snprintf(errbuf, sizeof errbuf, + "AFS authentication failed, %s", reason); logerr("Attempt by %s; %s", nbuf, errbuf); - return (errbuf); + return errbuf; } } #endif @@ -1789,7 +1790,7 @@ changeuid(char *namep, char *passwordp, break; #if CMUCS case ACCESS_CODE_INSECUREPWD: - (void) sprintf(errbuf, "Reason: %s", p); + snprintf(errbuf, sizeof errbuf, "Reason: %s", p); p = errbuf; break; case ACCESS_CODE_DENIED: @@ -1830,7 +1831,8 @@ changeuid(char *namep, char *passwordp, break; #endif /* CMUCS */ default: - (void) sprintf(p = errbuf, "Reason: Status %d", status); + snprintf(errbuf, sizeof errbuf, "Reason: Status %d", status); + p = errbuf; break; } if (status != ACCESS_CODE_OK) { Index: usr.sbin/sup/source/supscan.c =================================================================== RCS file: /cvsroot/src/usr.sbin/sup/source/supscan.c,v retrieving revision 1.24 diff -p -u -r1.24 supscan.c --- usr.sbin/sup/source/supscan.c 4 May 2017 16:26:10 -0000 1.24 +++ usr.sbin/sup/source/supscan.c 4 Oct 2019 11:58:37 -0000 @@ -284,7 +284,7 @@ init(int argc, char **argv) argv++; } if (!fflag) { - (void) sprintf(fbuf, FILEDIRS, DEFDIR); + snprintf(fbuf, sizeof fbuf, FILEDIRS, DEFDIR); filename = fbuf; } if (sflag) { @@ -292,7 +292,7 @@ init(int argc, char **argv) usage(); firstC = NULL; c = &firstC; - (void) sprintf(buf, FILEHOSTS, DEFDIR); + snprintf(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) { @@ -370,7 +370,7 @@ getscancoll(char *filename, char *collna (void) fclose(f); } if (basedir == NULL) { - (void) sprintf(buf, FILEBASEDEFAULT, collname); + snprintf(buf, sizeof buf, FILEBASEDEFAULT, collname); basedir = estrdup(buf); } } @@ -380,7 +380,7 @@ getscancoll(char *filename, char *collna return (NULL); } prefix = NULL; - (void) sprintf(buf, FILEPREFIX, collname); + snprintf(buf, sizeof buf, FILEPREFIX, collname); if ((f = fopen(buf, "r")) != NULL) { while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) { q = strchr(p, '\n');