diff options
author | alex <alex@FreeBSD.org> | 1996-10-26 04:08:57 +0000 |
---|---|---|
committer | alex <alex@FreeBSD.org> | 1996-10-26 04:08:57 +0000 |
commit | 882b44482bc81522bbe862d3a45b15e2821d7b3d (patch) | |
tree | 8070227fd197ece88d3be3c6a97154f6e52c8eb0 /usr.bin | |
parent | b5adba895dff2ddce29d9447ec23af1307a58cb8 (diff) | |
download | FreeBSD-src-882b44482bc81522bbe862d3a45b15e2821d7b3d.zip FreeBSD-src-882b44482bc81522bbe862d3a45b15e2821d7b3d.tar.gz |
sprintf --> snprintf
Use _PATH_DEV instead of hard coded "/dev/"
Obtained from: OpenBSD, Jason Downs <downsj@OpenBSD.ORG>
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/write/write.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c index fdd4827..601663b 100644 --- a/usr.bin/write/write.c +++ b/usr.bin/write/write.c @@ -51,6 +51,7 @@ static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93"; #include <sys/time.h> #include <utmp.h> #include <ctype.h> +#include <paths.h> #include <pwd.h> #include <stdio.h> #include <string.h> @@ -102,7 +103,7 @@ main(argc, argv) do_write(tty, mytty, myuid); break; case 3: - if (!strncmp(argv[2], "/dev/", 5)) + if (!strncmp(argv[2], _PATH_DEV, strlen(_PATH_DEV))) argv[2] += 5; if (utmp_chk(argv[1], argv[2])) { (void)fprintf(stderr, @@ -232,7 +233,7 @@ term_chk(tty, msgsokP, atimeP, showerror) struct stat s; 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 (showerror) (void)fprintf(stderr, @@ -264,7 +265,7 @@ do_write(tty, mytty, myuid) else login = "???"; - (void)sprintf(path, "/dev/%s", tty); + (void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty); if ((freopen(path, "w", stdout)) == NULL) { (void)fprintf(stderr, "write: %s: %s\n", path, strerror(errno)); exit(1); |