Allow longer commandlines in MOUNT and IMGMOUNT.
Fix crash reported by MiniMax (mount -u 0). Fix bug reported by Tearex ("config -get" broken). Add some protection that makes it harder to mount a directory from within an executable. Add some protection to make mounting from command /c much harder. Add a securemode commandline switch to config and dosbox that should make it impossible to mount a location when this isn't wanted by the user. (Addresses concerns of CVE-2007-6328) Update documentation to reflect this. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3114
This commit is contained in:
parent
f2c40b9407
commit
3f2e4fbd83
9 changed files with 156 additions and 38 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_programs.cpp,v 1.82 2008-01-19 11:02:29 qbix79 Exp $ */
|
||||
/* $Id: dos_programs.cpp,v 1.83 2008-03-02 11:13:46 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
#include <stdlib.h>
|
||||
|
@ -72,6 +72,7 @@ static void ResolveHomedir(std::string & temp_line) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class MOUNT : public Program {
|
||||
public:
|
||||
void Run(void)
|
||||
|
@ -80,11 +81,32 @@ public:
|
|||
std::string label;
|
||||
std::string umount;
|
||||
|
||||
//Hack To allow long commandlines
|
||||
ChangeToLongCmd();
|
||||
/* Parse the command line */
|
||||
/* if the command line is empty show current mounts */
|
||||
if (!cmd->GetCount()) {
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
|
||||
for (int d=0;d<DOS_DRIVES;d++) {
|
||||
if (Drives[d]) {
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),d+'A',Drives[d]->GetInfo());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* In secure mode don't allow people to change mount points.
|
||||
* Neither mount nor unmount */
|
||||
if(control->SecureMode()) {
|
||||
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for unmounting */
|
||||
if (cmd->FindString("-u",umount,false)) {
|
||||
umount[0] = toupper(umount[0]);
|
||||
int i_drive = umount[0]-'A';
|
||||
if(i_drive < DOS_DRIVES && Drives[i_drive]) {
|
||||
if(i_drive < DOS_DRIVES && i_drive >= 0 && Drives[i_drive]) {
|
||||
switch (DriveManager::UnmountDrive(i_drive)) {
|
||||
case 0:
|
||||
Drives[i_drive] = 0;
|
||||
|
@ -115,18 +137,6 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
/* Parse the command line */
|
||||
/* if the command line is empty show current mounts */
|
||||
if (!cmd->GetCount()) {
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
|
||||
for (int d=0;d<DOS_DRIVES;d++) {
|
||||
if (Drives[d]) {
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),d+'A',Drives[d]->GetInfo());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::string type="dir";
|
||||
cmd->FindString("-t",type,true);
|
||||
bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation
|
||||
|
@ -492,6 +502,15 @@ private:
|
|||
public:
|
||||
|
||||
void Run(void) {
|
||||
//Hack To allow long commandlines
|
||||
ChangeToLongCmd();
|
||||
/* In secure mode don't allow people to boot stuff.
|
||||
* They might try to corrupt the data on it */
|
||||
if(control->SecureMode()) {
|
||||
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *usefile_1=NULL;
|
||||
FILE *usefile_2=NULL;
|
||||
Bitu i;
|
||||
|
@ -946,8 +965,15 @@ static void INTRO_ProgramStart(Program * * make) {
|
|||
|
||||
class IMGMOUNT : public Program {
|
||||
public:
|
||||
void Run(void)
|
||||
{
|
||||
void Run(void) {
|
||||
//Hack To allow long commandlines
|
||||
ChangeToLongCmd();
|
||||
/* In secure mode don't allow people to change imgmount points.
|
||||
* Neither mount nor unmount */
|
||||
if(control->SecureMode()) {
|
||||
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
|
||||
return;
|
||||
}
|
||||
DOS_Drive * newdrive;
|
||||
imageDisk * newImage;
|
||||
Bit32u imagesize;
|
||||
|
@ -959,7 +985,7 @@ public:
|
|||
if (cmd->FindString("-u",umount,false)) {
|
||||
umount[0] = toupper(umount[0]);
|
||||
int i_drive = umount[0]-'A';
|
||||
if (i_drive < DOS_DRIVES && Drives[i_drive]) {
|
||||
if (i_drive < DOS_DRIVES && i_drive >= 0 && Drives[i_drive]) {
|
||||
switch (DriveManager::UnmountDrive(i_drive)) {
|
||||
case 0:
|
||||
Drives[i_drive] = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue