mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-29 13:15:05 +00:00
Fixed a potential buffer overflow problem, in the device name handling.
PR: bin/15101
This commit is contained in:
parent
73f2a3c2c8
commit
3712337aef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54164
|
@ -33,6 +33,7 @@ static const char rcsid[] =
|
|||
#include <sys/file.h>
|
||||
#include <sys/cdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <histedit.h>
|
||||
|
||||
#define VERSION "2.0"
|
||||
|
@ -1036,17 +1037,18 @@ char *parse (char *buf, int *cmd)
|
|||
|
||||
int open_cd ()
|
||||
{
|
||||
char devbuf[80];
|
||||
char devbuf[MAXPATHLEN];
|
||||
|
||||
if (fd > -1)
|
||||
return (1);
|
||||
|
||||
if (*cdname == '/')
|
||||
strcpy (devbuf, cdname);
|
||||
else if (*cdname == 'r')
|
||||
sprintf (devbuf, "/dev/%s", cdname);
|
||||
else
|
||||
sprintf (devbuf, "/dev/r%s", cdname);
|
||||
if (*cdname == '/') {
|
||||
snprintf (devbuf, MAXPATHLEN, "%s", cdname);
|
||||
} else if (*cdname == 'r') {
|
||||
snprintf (devbuf, MAXPATHLEN, "/dev/%s", cdname);
|
||||
} else {
|
||||
snprintf (devbuf, MAXPATHLEN, "/dev/r%s", cdname);
|
||||
}
|
||||
|
||||
fd = open (devbuf, O_RDONLY);
|
||||
|
||||
|
|
Loading…
Reference in a new issue