diff options
author | imp <imp@FreeBSD.org> | 1998-07-02 05:23:55 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1998-07-02 05:23:55 +0000 |
commit | 54c245f43c9c5cf58666fdff74ba338cfddd0384 (patch) | |
tree | e68a58e12ae2d5b35a0c891c2ca182db260c57b1 /usr.bin | |
parent | ed8a6f483dfed408aaf528f98d43f73f797f5842 (diff) | |
download | FreeBSD-src-54c245f43c9c5cf58666fdff74ba338cfddd0384.zip FreeBSD-src-54c245f43c9c5cf58666fdff74ba338cfddd0384.tar.gz |
o Be more careful about using sprintf and strcpy.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/doscmd/doscmd.c | 8 | ||||
-rw-r--r-- | usr.bin/doscmd/int17.c | 11 |
2 files changed, 10 insertions, 9 deletions
diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 80de3ba..7082dd2 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -29,7 +29,7 @@ * * BSDI doscmd.c,v 2.3 1996/04/08 19:32:30 bostic Exp * - * $Id: doscmd.c,v 1.4 1998/02/28 16:02:23 jraynard Exp $ + * $Id: doscmd.c,v 1.5 1998/07/01 19:56:14 imp Exp $ */ #include <sys/types.h> @@ -384,7 +384,7 @@ setup_command(int argc, char *argv[], regcontext_t *REGS) /* no PATH in DOS environment? put current directory there*/ if (i >= ecnt) { static char path[256]; - sprintf(path, "PATH=C:%s", dos_getcwd(drlton('C'))); + snprintf(path, sizeof(path), "PATH=C:%s", dos_getcwd(drlton('C'))); put_dosenv(path); dos_path = envs[ecnt-1] + 5; } @@ -456,13 +456,13 @@ find_doscmdrc(void) if ((fp = fopen(".doscmdrc", "r")) == NULL) { struct passwd *pwd = getpwuid(geteuid()); if (pwd) { - sprintf(buffer, "%s/.doscmdrc", pwd->pw_dir); + snprintf(buffer, sizeof(buffer), "%s/.doscmdrc", pwd->pw_dir); fp = fopen(buffer, "r"); } if (!fp) { char *home = getenv("HOME"); if (home) { - sprintf(buffer, "%s/.doscmdrc", home); + snprintf(buffer, sizeof(buffer), "%s/.doscmdrc", home); fp = fopen(buffer, "r"); } } diff --git a/usr.bin/doscmd/int17.c b/usr.bin/doscmd/int17.c index 4c68ef3..8862191 100644 --- a/usr.bin/doscmd/int17.c +++ b/usr.bin/doscmd/int17.c @@ -29,7 +29,7 @@ * * BSDI int17.c,v 2.2 1996/04/08 19:32:48 bostic Exp * - * $Id: int17.c,v 1.1 1997/08/09 01:42:48 dyson Exp $ + * $Id: int17.c,v 1.2 1998/01/22 02:44:54 msmith Exp $ */ #include "doscmd.h" @@ -152,12 +152,13 @@ open_printer(int printer) /* * If printer is a spooled device then open pipe to spooled device */ - if (queue[printer]) - strcpy(printer_name, queue[printer]); - else + if (queue[printer]) { + strncpy(printer_name, queue[printer], sizeof(printer_name)); + printer_name[sizeof(printer_name) - 1] = '\0'; + } else strcpy(printer_name, "lp"); - sprintf(command, "lpr -P %s", printer_name); + snprintf(command, sizeof(command), "lpr -P %s", printer_name); debug(D_PRINTER, "opening pipe to %s\n", printer_name); if ((file = popen(command, "w")) == 0) { |