mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 08:44:33 +00:00
sprintf --> snprintf
Use _PATH_DEV instead of hard coded "/dev/" Obtained from: OpenBSD, Jason Downs <downsj@OpenBSD.ORG>
This commit is contained in:
parent
a3f90e9bd5
commit
2d754ac864
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19190
|
@ -51,6 +51,7 @@ static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <paths.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -102,7 +103,7 @@ main(argc, argv)
|
||||||
do_write(tty, mytty, myuid);
|
do_write(tty, mytty, myuid);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (!strncmp(argv[2], "/dev/", 5))
|
if (!strncmp(argv[2], _PATH_DEV, strlen(_PATH_DEV)))
|
||||||
argv[2] += 5;
|
argv[2] += 5;
|
||||||
if (utmp_chk(argv[1], argv[2])) {
|
if (utmp_chk(argv[1], argv[2])) {
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
|
@ -232,7 +233,7 @@ term_chk(tty, msgsokP, atimeP, showerror)
|
||||||
struct stat s;
|
struct stat s;
|
||||||
char path[MAXPATHLEN];
|
char path[MAXPATHLEN];
|
||||||
|
|
||||||
(void)sprintf(path, "/dev/%s", tty);
|
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
|
||||||
if (stat(path, &s) < 0) {
|
if (stat(path, &s) < 0) {
|
||||||
if (showerror)
|
if (showerror)
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
|
@ -264,7 +265,7 @@ do_write(tty, mytty, myuid)
|
||||||
else
|
else
|
||||||
login = "???";
|
login = "???";
|
||||||
|
|
||||||
(void)sprintf(path, "/dev/%s", tty);
|
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
|
||||||
if ((freopen(path, "w", stdout)) == NULL) {
|
if ((freopen(path, "w", stdout)) == NULL) {
|
||||||
(void)fprintf(stderr, "write: %s: %s\n", path, strerror(errno));
|
(void)fprintf(stderr, "write: %s: %s\n", path, strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in a new issue