o Be more careful about using sprintf and strcpy.

This commit is contained in:
imp 1998-07-02 05:23:55 +00:00
parent ed8a6f483d
commit 54c245f43c
2 changed files with 10 additions and 9 deletions

View File

@ -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");
}
}

View File

@ -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) {