mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-26 00:55:14 +00:00
* Fix the intended functionality of the previous commit (i.e. /dev/<dev>c,
/dev/<dev>, and <dev> are all searched) * Fix a potential buffer overflow introduced by the previous commit * Fix a memory leak introduced in the previous commit * Fix the case where <dev> is not a symlink * Reset maintainer to ports@ Approved by: shige (previous maintainer)
This commit is contained in:
parent
707d96d94c
commit
380e61ac3c
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=96548
@ -7,13 +7,13 @@
|
||||
|
||||
PORTNAME= eject
|
||||
PORTVERSION= 1.4
|
||||
PORTREVISION= 1
|
||||
PORTREVISION= 2
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= ftp://ports.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
|
||||
ftp://ftp4.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
|
||||
ftp://ftp.ics.es.osaka-u.ac.jp/pub/mirrors/FreeBSD-jp/OD/
|
||||
|
||||
MAINTAINER= shige@FreeBSD.org
|
||||
MAINTAINER= ports@FreeBSD.org
|
||||
COMMENT= Utility for ejecting media from CD or optical disk drive
|
||||
|
||||
DOCDIR= share/doc/eject
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- eject.c.orig Tue Jan 4 06:42:12 2000
|
||||
+++ eject.c Mon Sep 29 07:16:58 2003
|
||||
--- eject.c.orig Tue Jan 4 09:42:12 2000
|
||||
+++ eject.c Wed Dec 24 01:11:34 2003
|
||||
@@ -43,8 +43,8 @@
|
||||
extern int optind;
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
char *defdev;
|
||||
|
||||
fflag = nflag = vflag = 0;
|
||||
@@ -95,18 +95,27 @@
|
||||
@@ -95,18 +95,28 @@
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
}
|
||||
@ -41,8 +41,9 @@
|
||||
+ } else {
|
||||
+ int c;
|
||||
+ char *dev_bak = malloc(MAXPATHLEN);
|
||||
+ if (c = readlink(device, dev_bak, MAXPATHLEN)) {
|
||||
+ if ((c = readlink(device, dev_bak, MAXPATHLEN-1)) != -1) {
|
||||
+ dev_bak[c] = '\0';
|
||||
+ free(name);
|
||||
+ name = dev_bak;
|
||||
+ } else {
|
||||
+ free(dev_bak);
|
||||
@ -54,7 +55,7 @@
|
||||
if (sts < 0) {
|
||||
perror(err);
|
||||
exit(1);
|
||||
@@ -128,16 +137,26 @@
|
||||
@@ -128,16 +138,26 @@
|
||||
int
|
||||
check_device(name, device)
|
||||
char *name;
|
||||
@ -62,15 +63,15 @@
|
||||
+ char **device;
|
||||
{
|
||||
- int sts;
|
||||
+ int sts, i;
|
||||
+ int sts = 0, i;
|
||||
struct stat sb;
|
||||
|
||||
- sprintf(device, "/dev/r%sc", name);
|
||||
- if (vflag || nflag) {
|
||||
- printf("%s: using device %s\n", program, device);
|
||||
+ const char* dev_list[] = { "/dev/%sc", "/dev/%s", "%s" };
|
||||
+ for (i = 0; i < 2; i++) {
|
||||
+ if (asprintf(device, dev_list[i], name) == -1)
|
||||
+ const char* dev_list[] = { "/dev/%sc", "/dev/%s", "%s", NULL };
|
||||
+ for (i = 0; dev_list[i]; i++) {
|
||||
+ if ((sts = asprintf(device, dev_list[i], name)) == -1)
|
||||
+ return sts;
|
||||
+ if (vflag || nflag) {
|
||||
+ printf("%s: trying device %s\n", program, *device);
|
||||
@ -87,7 +88,7 @@
|
||||
|
||||
return sts;
|
||||
}
|
||||
@@ -155,7 +174,7 @@
|
||||
@@ -155,7 +175,7 @@
|
||||
int
|
||||
unmount_fs(name, err)
|
||||
char *name;
|
||||
@ -96,7 +97,7 @@
|
||||
{
|
||||
int mnts;
|
||||
struct statfs *mntbuf;
|
||||
@@ -221,7 +240,7 @@
|
||||
@@ -221,7 +241,7 @@
|
||||
sts = 0;
|
||||
}
|
||||
if (sts < 0 && fflag == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user