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.
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.
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.
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.
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).
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.
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).
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.
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.
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/