aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2001-01-19 23:11:18 +0000
committerKris Kennaway <kris@FreeBSD.org>2001-01-19 23:11:18 +0000
commit4dedca9fd7ce4e8a3d1e1c041bc7fb5af2522cc7 (patch)
tree9b9a4f752c11dfeebd0edb211c6aa4511562eef9 /usr.sbin
parentb94ec3184fbe48497c93ab48d6763fb394ec43e4 (diff)
downloadsrc-4dedca9fd7ce4e8a3d1e1c041bc7fb5af2522cc7.tar.gz
src-4dedca9fd7ce4e8a3d1e1c041bc7fb5af2522cc7.zip
Prevent overflow in -d argument by replacing hand-rolled
strcat+strcpy+perror with err() Submitted by: Mike Heffner <mheffner@vt.edu>
Notes
Notes: svn path=/head/; revision=71270
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pcvt/cursor/cursor.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/usr.sbin/pcvt/cursor/cursor.c b/usr.sbin/pcvt/cursor/cursor.c
index 2798f57267dc..01bdd102b376 100644
--- a/usr.sbin/pcvt/cursor/cursor.c
+++ b/usr.sbin/pcvt/cursor/cursor.c
@@ -45,6 +45,7 @@ static char *id =
*---------------------------------------------------------------------------*/
#include <stdio.h>
+#include <err.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <machine/pcvt_ioctl.h>
@@ -101,31 +102,15 @@ char *argv[];
{
fd = DEFAULTFD;
}
- else
- {
- if((fd = open(device, O_RDWR)) == -1)
- {
- char buffer[80];
- strcpy(buffer,"ERROR opening ");
- strcat(buffer,device);
- perror(buffer);
- exit(1);
- }
- }
+ else if((fd = open(device, O_RDWR)) == -1)
+ err(1, "ERROR opening %s", device);
if(screen == -1)
{
struct stat stat;
if((fstat(fd, &stat)) == -1)
- {
- char buffer[80];
- strcpy(buffer,"ERROR opening ");
- strcat(buffer,device);
- perror(buffer);
- exit(1);
- }
-
+ err(1, "ERROR opening %s", device);
screen = minor(stat.st_rdev);
}
@@ -134,10 +119,7 @@ char *argv[];
cursorshape.screen_no = screen;
if(ioctl(fd, VGACURSOR, &cursorshape) == -1)
- {
- perror("cursor - ioctl VGACURSOR failed, error");
- exit(1);
- }
+ err(1, "cursor - ioctl VGACURSOR failed, error");
else
exit(0);
}