1
0
Fork 0
Commit graph

4075 commits

Author SHA1 Message Date
Patryk Obara
7f0d07fd1b Fix format warnings in cpu (dh_fpu_esc3) 2020-03-01 21:23:04 +01:00
Patryk Obara
716acd09e8 Prevent null pointer dereference when checking program args
First parameter to function 'strchr' is marked a nonnull. If null is
passed as args there's no point in looking for flags.  This function is
always used in the beginning of all internal macros through HELP macro
to detect /? flag.
2020-03-01 21:23:04 +01:00
Patryk Obara
2bbe181ccb Avoid integer overflow in bios_disk
Coverity warns about potential integer overflow on 32-bit value before
widening the calculation result to 64-bit.
2020-03-01 21:23:04 +01:00
Patryk Obara
19d1caa483 Avoid division by zero when initializing pcspeaker
Coverity detects possible division by zero in calculation of spkr.min_tr
few lines below; this is a false-positive issue detected by Coverity,
but only bacause int value passed by user has a set of pre-determined
values.  We can as well make sure that value is never going to be
smaller than the minimum allowed.
2020-03-01 21:23:04 +01:00
Patryk Obara
d47450c6d7 Fix memory leak in dos_execute 2020-03-01 21:23:04 +01:00
Anton Shepelev
9ae663ca12 Include <ctype.h> to declare toupper() 2020-03-01 21:13:19 +01:00
Patryk Obara
9fc21dc294 Allow GNU extensions for GCC to avoid MinGW bugs
Most MinGW versions work correctly with and without _POSIX_C_SOURCE
or XOPEN macros [1] and don't need any special handling, but some
installations refuse to work correctly.

To be more precise: *some* MinGW installations turn off POSIX support
after turning on -std=c++11 WITHOUT -ansi -Wpedantic, -pedantic-errors
and similar.  This behaviour is inconsistent between various Windows
versions and MinGW distributions and manifests itself only when using
GCC (Clang behaves correctly).

[1] https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2020-03-01 21:13:19 +01:00
Patryk Obara
d0da4341fe Include cassert header in vga 2020-02-26 13:06:22 +01:00
Patryk Obara
cd93ea9507 Silence buffer overrun Coverity warning
This buffer overrun could happen if implementer forgets to fill pointer
svga.set_clock, but calls VGA_SetClock with index out of bounds.
Placing assert in here should clear out false positives detected by
Coverity.
2020-02-26 12:59:41 +01:00
Patryk Obara
e2196a77e2 Silence buffer overflow false-positives
Coverity reports a number of buffer overflows here.

The code was written in a way, that effectively made it hard for static
analysis to prove the buffer overflow does not happen, but the code
itself was safe.

Update it to avoid repetition and use snprintf, that guarantees no
buffer overflow will happen, and buffer will always be zero-delimited.
2020-02-26 11:08:28 +01:00
Patryk Obara
b58ad366fc Silence few false-positive buffer overflow issues 2020-02-26 11:08:28 +01:00
Patryk Obara
dc55ccb21f Fix buffer overflow in CMD_PATH
This buffer overflow was easy to trigger by just running:

  Z:\> path <very-long-string>

We avoid the problem by using snprintf, which will trim input to
the length passed as second parameter.
2020-02-26 11:08:28 +01:00
Patryk Obara
5e41eaf150 Merge branch 'svn/trunk' r4333
Conflict resolutions required some algorithm adjustments.
2020-02-25 11:11:00 +01:00
Peter Veenstra
5afd7057f3 Optimize xchg a bit. (jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4333
2020-02-24 20:02:58 +00:00
Peter Veenstra
5d654fc5c5 Make value operator== const, add some limit checks in PrintConfigfile and related functions. Unify style a bit more.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4332
2020-02-24 20:00:55 +00:00
Peter Veenstra
6a1a1eff9c missing line ends and a warning fix
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4331
2020-02-24 19:57:20 +00:00
krcroft
6c0e1a4607 Switch write protected set to unordered_set 2020-02-24 12:08:01 +01:00
krcroft
b302b535c3 Add DEBUG messages for protected-file handling 2020-02-24 12:08:01 +01:00
krcroft
9603c961c0 Fix spacing and effc++ warnings
Apply code review recommendations
2020-02-24 12:07:53 +01:00
krcroft
c730e5d70a
Permit the use of protected game data files
Many DOS games open all their files in write-mode regardless if the
game actually intends to write to them or not.

This can result the files' metadata being updated (lossing the
original date-stamp) as well as putting the file at-risk of
corruption if the game crashes with the file open for writing.

Under the existing DOSBox implementation, if a user attempts to
write-protect their data files then DOSBox will quit with an error in
the above scenario.

This commit allows the use of write-protected files (similar to
running a game from CDROM) and indicates which files are being
actively protected against modification.

Typically the only files that need to be left writable are those that
the game actually changes, such as: save-game files, highscore
files, in-game settings, and so on.  If these are also protected,
then the game will quit/crash immediately after the protected message
is printed, and thus indicate which file require write-allowance.
2020-02-23 21:45:20 -08:00
krcroft
6804faf931 Fix a pointer invalidation corner-case in CD-DA 2020-02-23 13:08:08 +01:00
Patryk Obara
c619445003 Avoid buffer underflow by copying all fields
This code made silent assumption that first fields in direntry are
exactly 14 bytes - this was fine, except would break as soon as anyone
would touch the struct (or e.g. if a compiler would lack support for
packed structures and inject some padding in there); rewrite the copy
code to follow the same pattern as other fields - now the code will be
fine even if someone will change fields in the direntry struct.

Fixes 2 PVS static analysis issues (buffer underflow on src and dst).
2020-02-23 01:13:11 +01:00
Patryk Obara
6011c016c5 Replace var_read with host_to_le where possible
Effect is the same, except packed values are not referenced via pointer
so there's no address-of-packed-member warning, and no need for
unaligned memory access.
2020-02-22 22:47:40 +01:00
Patryk Obara
bdf67cdbcc Merge branch 'svn/trunk' r4330 2020-02-22 21:10:57 +01:00
Patryk Obara
28ebbd3bed Revert "Enhance capturing to handle unchanged screens (…)" r4329
This reverts commit fd11108206.
2020-02-22 20:59:59 +01:00
Peter Veenstra
57bf045cc8 some big endian improvents and drive_fat fixes. (jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4330
2020-02-22 12:06:40 +00:00
Patryk Obara
8703917a02 Fix window position when starting in fullscreen 2020-02-21 01:20:16 +01:00
Patryk Obara
c77638bb18 Fix window position when switching to windowed mode 2020-02-21 01:20:16 +01:00
krcroft
438870c75f Only resize the sendbuffer if needed 2020-02-19 19:25:47 +01:00
krcroft
fa64d98a52 Be explicit when we lose precision and change signedness 2020-02-19 19:25:47 +01:00
krcroft
4d34a80e7f Use K&R indents with some if statements 2020-02-19 19:25:47 +01:00
krcroft
7df5a30f98 Simplify by using the _TCPsocketX struct as-is
Unlike an array of 1-byte chars which only requires 1-byte
alignment (because the array's largest element is only one byte),
when we fool the compiler into allocating a _TCPsocketX as an arra
of chars, we similarly tell the compiler we only need 1-byte
alignment. But this requirement changes when we cast the 1-byte array
back to the _TCPsocketX and try to operate on members having sizes
larger than 1-byte (such as int32's); we now require 4-byte
alignment (after allocation).
2020-02-19 19:25:47 +01:00
Patryk Obara
6468e3c149 Initialize TCPsocket to nullptr
This typedef originates from SDL_net.h, it's an opaque data type used
for TCP connections.

It's a pointer, therefore prevent copying and assignment in
TCPServerSocket to prevent ownership problems.
2020-02-19 19:25:47 +01:00
Patryk Obara
75478a9a39 Make TCPClientSocket field private
Also, it is a pointer, therefore prevent bugs by disallowing copying
and assignment.
2020-02-19 19:25:47 +01:00
Patryk Obara
0e32c002ae Cleanup ifdef guards in serialport misc util 2020-02-19 19:25:47 +01:00
Patryk Obara
651aeb906c Initialize missed fields in TCPClientSocket
Also, do some code and style cleanup in c-tors.
2020-02-19 19:25:47 +01:00
Patryk Obara
534a603cb8 Remove some duplicated code in serialport
Reuse SendArray implementation instead of repeating the same code
pattern several times.

This change started as a removal of warning about comparison of
integer expressions of different signedness: ‘int’ and ‘Bitu’
(when comparing return value of SDLNet_TCP_Send), but turned into
a small cleanup and removal of dead code.
2020-02-19 19:25:47 +01:00
krcroft
c132263116 Add partial DAE support for compressed Redbook-compliant tracks 2020-02-18 18:54:41 +01:00
krcroft
fdf103a111
Fix sector 0 playback bug
This bug prevented reporting of correct playback position on
pure-audio CDs with zero PREGAP.
2020-02-17 12:19:21 -08:00
Peter Veenstra
fd11108206 Enhance capturing to handle unchanged screens more efficiently(jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4329
2020-02-17 16:20:07 +00:00
Patryk Obara
5bd3a4ac8d Merge branch 'svn/trunk' r4328 2020-02-15 21:27:20 +01:00
Marco Maccaferri
4aee47a770
Fix handling of escape characters in softmodem
When running BBS DOSBox's softmodem does not correctly handle
escape characters properly nor does it properly transition
to command mode:

Characters are swallowed instead of passed-through, this causes
issue when transmitting strings with the plus character.
Additional characters before and after the escape sequence don't
reset the counters causing switch to command mode even if not
intended. For example, connect to a remote and type a+++ it
switches to command mode, it should not. The attached proposed
patch fixes the escape handling:

Transmission pause is checked before and after the escape
sequence, so <pause>+++<pause> is the correct
sequence.</pause></pause> Extra characters cause the counters to
be reset so no unwanted switch is triggered. Use register S12 to
set the pause timer in 1/50th of seconds, default is 50 = 1 sec.
Plus characters are passed to the remote. With this fix I'm able
to run a BBS software and do file transfers with XModem and ZModem
without problems.

Imported-from: https://sourceforge.net/p/dosbox/patches/287/
2020-02-15 11:34:33 -08:00
Patryk Obara
6e89827d2b Change 'sblaster.oplemu = default' to select 'nuked'
Nuked emulator implementation seems to be the preferred one by the most
users at the moment.
2020-02-15 19:10:20 +01:00
Patryk Obara
47e3e02190 Change 'render.glshader' default to 'sharp' 2020-02-15 19:10:20 +01:00
Patryk Obara
6ffe13d81f Change 'sdl.fullresolution' default to 'desktop'
It works the same as 0x0, except it's documented in help string. Remove
the misleading and old comments from the help string.
2020-02-15 19:10:20 +01:00
Patryk Obara
040e47372e Change 'sdl.capture_mouse' default to 'seamless middlerelease'
Also, reformat help string, so that help comment generated in default
.conf file sort-of matches 80 columns.
2020-02-15 19:10:20 +01:00
Patryk Obara
9fee755542 Change 'sdl.output' default to 'opengl'
When OpenGL support is disabled during compilation, previous default of
'texture' is preserved.
2020-02-15 19:10:20 +01:00
Patryk Obara
bb7e202d2c Print newline after 'config -axadd' 2020-02-15 19:10:20 +01:00
Patryk Obara
0b505db4d8 Print newline after 'config -wcd' 2020-02-15 19:10:20 +01:00
Patryk Obara
8c8b1b58d7 Print newline after 'config -l' 2020-02-15 19:10:20 +01:00