summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd/int17.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-07-02 05:23:55 +0000
committerimp <imp@FreeBSD.org>1998-07-02 05:23:55 +0000
commit54c245f43c9c5cf58666fdff74ba338cfddd0384 (patch)
treee68a58e12ae2d5b35a0c891c2ca182db260c57b1 /usr.bin/doscmd/int17.c
parented8a6f483dfed408aaf528f98d43f73f797f5842 (diff)
downloadFreeBSD-src-54c245f43c9c5cf58666fdff74ba338cfddd0384.zip
FreeBSD-src-54c245f43c9c5cf58666fdff74ba338cfddd0384.tar.gz
o Be more careful about using sprintf and strcpy.
Diffstat (limited to 'usr.bin/doscmd/int17.c')
-rw-r--r--usr.bin/doscmd/int17.c11
1 files changed, 6 insertions, 5 deletions
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) {
OpenPOWER on IntegriCloud