diff options
author | kris <kris@FreeBSD.org> | 2001-01-19 23:11:18 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2001-01-19 23:11:18 +0000 |
commit | 1a613000805b6793f1e8b2e2fca1afecd69beba8 (patch) | |
tree | 8498cbf708d1f301c7191a80f033646f56d1194b /usr.sbin/pcvt | |
parent | 0ee7383b5a5b95018082d0847d81e4954d91f538 (diff) | |
download | FreeBSD-src-1a613000805b6793f1e8b2e2fca1afecd69beba8.zip FreeBSD-src-1a613000805b6793f1e8b2e2fca1afecd69beba8.tar.gz |
Prevent overflow in -d argument by replacing hand-rolled
strcat+strcpy+perror with err()
Submitted by: Mike Heffner <mheffner@vt.edu>
Diffstat (limited to 'usr.sbin/pcvt')
-rw-r--r-- | usr.sbin/pcvt/cursor/cursor.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/usr.sbin/pcvt/cursor/cursor.c b/usr.sbin/pcvt/cursor/cursor.c index 2798f57..01bdd10 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); } |