1
0
Fork 0
Commit graph

72 commits

Author SHA1 Message Date
kcgen
e603337c17 Limit string copies to the target's length
This commits covers a single class of string-copy
issues, all of which involve writing an unchecked
quantity of bytes into a string of a fixed length (ie:
char[]).
2020-05-01 17:27:47 +02:00
Joshua Fern
f2029d71d8 Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
Patryk Obara
2983de4db4 Use unsigned for numbers in shortened filenames
Bitu (aka uintptr_t) is not necessary for handling shortened files,
as we can represent max 10^7 shortened files anyway; unsigned is good
enough.

This allows use to use simple %u for conversion instead of PRIuPTR,
which caused a bug on AmigaOS on PPC.

Fixes: #162
2020-02-06 09:24:05 +01:00
Patryk Obara
4a6704367b Reorder includes for drive_cache
Class DOS_Drive_Cache is declared in dos_system.h, but this header was
indirectly included.  Remove faulty windows.h include (the correct one
exists in cross.h already).
2020-02-06 09:24:05 +01:00
Patryk Obara
381dd8be87 Make setter for RO-medium flag a virtual method
This way we prevent pointless dynamic_cast; correct usage of
dynamic_cast requires a nullcheck, which was missing in this case
causing Coverity to complain.

Instead of changing cast, let's make this method a virtual one in base
class - this way we could reuse it in future for cases outside of CD-ROM
(e.g. write-protected floppies).
2020-01-11 20:52:55 +01:00
Patryk Obara
2694aca2b2 Fix effc++ warnings in drives.cpp 2020-01-04 08:26:22 +01:00
krcroft
c9198b2944 Fix unsafe memory operations and warnings in the fatDrive class
- Move imageDiskList from pointer to vector of unique_ptr
- Replace string operations with size-limited versions
- Initialize members
- Eliminate unecessary casts
- Eliminate memory-leak on pointer assignment
2019-12-09 08:19:26 +01:00
krcroft
48106d6046 Explicitly delete copy and assignment operators 2019-12-07 21:07:38 +01:00
krcroft
8c6758c8d1 Memory overrun and C++11 updates
- Limit write length into buffer, and add comment about corner-case
- Use C++11's syntax to explicitly remove private copy and assignment operators
- Use C++11 container loop syntax to shorting a cleanup function
2019-12-07 19:08:47 +01:00
krcroft
cff6b05559 Improve memory safety in the DOS Drive Cache class
- Fix Bitu printf format type
- Check a pointer prior to dereferencing it
- Prevent writing one-beyond the last index
- Replace strcpy with with helper safe_strcpy, provided by @dreamer - thank you!
- Replace strcat with strncat
- Add constructor intializers for scalars and arrays
- Initialize and replace 0-value pointers with nullptr
- Pass in the buffer length when strncpy'ing into a function variable
2019-12-07 19:08:47 +01:00
Patryk Obara
6c42f3adf8 Fix several unused-private-field warnings 2019-11-24 17:14:32 +01:00
Peter Veenstra
a533565297 Init some more fields in the constructors, else uninited stuff gets copied in copy constructors.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4289
2019-11-15 18:37:20 +00:00
Peter Veenstra
f8dd3db095 Add functionality to add overlay directories to drive_cache.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4216
2019-04-22 14:21:53 +00:00
Peter Veenstra
202bfa1155 New Drive type: overlay.
When active, this drive redirects new and changed files to a different location.
The files in the overlay and normal drive are merged on startup and kept up to date when the game changes something. 
Files in the overlay are priotizedi, if they exists, above the normal files. 
The drive will switch to an overlayed version of the file on the first write! (Not when opening the file in write-mode).
The overlay is capable of creating missing directories.

With the help of DBOVERLAY files, the drive keeps track of files that are present in the normal directory but deleted by the game. 
All changes are preserved between sessions. 

Current design principles/limitations/requirements:
1) All directories that can be used for saving, must exist already in the base before mounting. (they will be created by DOSBox if missing in the overlay)
2) All filenames inside the overlay directories are UPPERCASE and conform to the 8.3 standard except for the special DBOVERLAY files.
3) To keep point 1 valid at all times, support for creating/renaming/removing directories has been disabled.

Thanks for the help GOG.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4196
2019-03-25 13:49:25 +00:00
Peter Veenstra
1fbaff47fc Update year and address of FSF
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4183
2019-01-25 14:09:58 +00:00
Peter Veenstra
5bb10db88b Time keeps on ticking
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4109
2018-05-29 12:58:58 +00:00
Peter Veenstra
21a0040650 Move definition of LocalFile to header file, requested by bruenor41, makes sense to make it available at a larger scope.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4058
2017-10-10 14:21:31 +00:00
Peter Veenstra
6cf39c1fc6 Years update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4021
2017-05-30 11:35:08 +00:00
Peter Veenstra
0f4c92ca32 Year update.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3878
2015-01-06 14:40:32 +00:00
Peter Veenstra
2fea508f7f Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3812
2013-01-15 09:03:13 +00:00
Peter Veenstra
999f33de27 Update year. Remove CVS tags
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3700
2011-04-26 09:34:55 +00:00
Peter Veenstra
eaf55b8dfd Add dummy support for openmode 4. Legend Of the Red Dragon 4.07 uses this.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3667
2011-01-16 20:49:43 +00:00
Peter Veenstra
0438430b24 Add patch 3011706 by bredbored: remove double weirdness with free and dirsearch being 0. More sensible clearing of the directory cache. Fixes skynet crashes related to corrupted drive cache.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3630
2010-08-07 18:25:24 +00:00
Peter Veenstra
a78b2c4f8b Update year
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3548
2010-02-11 13:36:50 +00:00
Peter Veenstra
38c99cbf12 Add more intelligence to the findfirst stored lists cleanup algorithm
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3535
2010-01-13 18:31:21 +00:00
Sebastian Strohhäcker
2fd9c8f349 use fast filesearch routines for directory cache
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3315
2009-03-04 21:08:22 +00:00
Sebastian Strohhäcker
e08513aece fix file shortener ID of the drive cache (under rare conditions, bug recently introduced);
use better/faster method to copy the drive cache contents for findfirst, directly related to
the shortname bug found+analyzed by Alexander Katz (sf patch #2194354)


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3310
2009-02-28 11:34:10 +00:00
Sebastian Strohhäcker
ad13c63c32 avoid using stat calls if possible (reusing cached data if needed)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3308
2009-02-24 17:56:55 +00:00
Sebastian Strohhäcker
9725773407 keep drive cache lists sorted on insert to avoid full sort calls
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3307
2009-02-20 14:19:47 +00:00
Sebastian Strohhäcker
c78a9f6c03 fix/work around some gcc Wall warnings
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3192
2008-08-06 18:34:21 +00:00
Peter Veenstra
c7b676198f Add DOS_ATTR_DEVICE
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3144
2008-04-16 19:31:05 +00:00
Peter Veenstra
ac66214dab Emulate a trailing dot on volume labels of 8 characters when on a cdrom drive. mscdex weirdness. Fixes Fifa96 cdrom detection.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3033
2007-11-01 12:15:34 +00:00
Peter Veenstra
df0f8ee9d6 Remove from DOS_File type and size. type wasn't used at all. size was only implemented in 50% of the drives.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2885
2007-06-13 07:25:14 +00:00
Sebastian Strohhäcker
e608297aae add imagedisk swapping capabilities (prompt, slightly modified sf patch #1505951); fix int13 write sectors return code
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2778
2007-01-21 16:21:22 +00:00
Peter Veenstra
fdd16dea1a Happy New Year\!
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2728
2007-01-08 19:45:42 +00:00
Sebastian Strohhäcker
af1673c6f2 re-fix deleting of hostwise open files (makes Alien Carnage work again without breaking Abuse)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2722
2006-11-14 20:01:42 +00:00
Peter Veenstra
3ea5a913a9 Add rewriten form of patch "[ 1498334 ] CD Images unmounting" created by Kronutz
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2658
2006-06-22 13:15:07 +00:00
Sebastian Strohhäcker
e332fed532 return drive and not-written bit for ioctl function 0
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2614
2006-04-23 14:20:58 +00:00
Peter Veenstra
8b7b77b21e Isname should use strcasecmp as it deals with emulated DOS file names.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2598
2006-04-15 15:53:37 +00:00
Peter Veenstra
57d8180da8 Remove DOS_No_Drive_Cache. Didn't compile anymore since 0.60.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2591
2006-04-10 12:52:47 +00:00
Sebastian Strohhäcker
3359eee956 add device control channel handling;
fix typo in ems.cpp (#1462677)


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2582
2006-04-07 16:34:07 +00:00
Peter Veenstra
df67775306 time passes on and on....
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2480
2006-02-09 11:47:57 +00:00
Peter Veenstra
ebd0dc79d9 new include system + support for the removal of devices + new function for labels (mechwarrior 2)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2141
2005-03-24 21:12:30 +00:00
Peter Veenstra
2094d8b985 Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2106
2005-02-10 10:21:12 +00:00
Peter Veenstra
b2c2a02c97 Don't update the drive-label if one was specified at mount time. Be more flexible with directorie mounting (don't care about a trailing slash)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2057
2004-11-13 12:08:43 +00:00
Peter Veenstra
e9df6e56ab Change fpu for Elvira. Added isRemovable to drive for dott.cd and alike.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2047
2004-11-03 23:13:55 +00:00
Peter Veenstra
8dbbd230da forgot return statement
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2032
2004-10-20 12:27:19 +00:00
Peter Veenstra
3602a06de9 Rewrote devices so they can be opened/closed/cloned. Fix Turbo pascal 7 saving bug(wd/mirek). Increase number of files to 127. Remove null device from default handles. Proper creation of the initial psp. (not hacked anymore). Quite some files= bugs should be fixed
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2025
2004-10-17 14:45:00 +00:00
Peter Veenstra
ca409fd57c Typo in preamble
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1899
2004-08-04 09:12:57 +00:00
Peter Veenstra
67253f9e9b Added support for attribute searching with extend fcbs.
Added support for volume label searching on Virtual Drives.
Added warnings for volume searching on Drive Fat.
Improved support for Filelabel searching on drive_local to include fcbfinds
Added Drivelabel "DOSBOX" to Virtual Drives.
Changed default Label for localdrives to "NO_LABEL".
Made DOS_FindFirst fcb finds aware.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1770
2004-04-18 14:49:50 +00:00