mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 17:32:13 +00:00
cache1d.c: Revert changes in r4665 unrelated to unrolling, fixing oob write.
Specifically, we must make sure that dasizeof <= LZWSIZE (or so) in c1d_{read,write}_compressed() (what the assertion in the last commit was about, and is now redundant). This fixes saving of e.g. large gamearrays with the C-CON build. Bump BYTEVERSION. An alternative for setting dasizeof to 1 would be to factor it and keep dividing as long as it's > LZWSIZE. git-svn-id: https://svn.eduke32.com/eduke32@4838 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b7805868f7
commit
7da543e4f0
2 changed files with 7 additions and 27 deletions
|
@ -1466,26 +1466,16 @@ C1D_STATIC int32_t c1d_read_compressed(void *buffer, bsize_t dasizeof, bsize_t c
|
||||||
char *ptr = (char *)buffer;
|
char *ptr = (char *)buffer;
|
||||||
|
|
||||||
if (dasizeof > LZWSIZE)
|
if (dasizeof > LZWSIZE)
|
||||||
{
|
|
||||||
if (count > LZWSIZE)
|
|
||||||
{
|
{
|
||||||
count *= dasizeof;
|
count *= dasizeof;
|
||||||
dasizeof = 1;
|
dasizeof = 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
uint32_t i = count;
|
|
||||||
count = dasizeof;
|
|
||||||
dasizeof = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t kgoal;
|
uint32_t kgoal;
|
||||||
|
|
||||||
if (decompress_part(f, &kgoal))
|
if (decompress_part(f, &kgoal))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Bassert(dasizeof < sizeof(lzwrawbuf));
|
|
||||||
Bmemcpy(ptr, lzwrawbuf, (int32_t)dasizeof);
|
Bmemcpy(ptr, lzwrawbuf, (int32_t)dasizeof);
|
||||||
|
|
||||||
uint32_t k = (int32_t)dasizeof;
|
uint32_t k = (int32_t)dasizeof;
|
||||||
|
@ -1545,22 +1535,12 @@ C1D_STATIC void c1d_write_compressed(const void *buffer, bsize_t dasizeof, bsize
|
||||||
{
|
{
|
||||||
const char *ptr = (char*)buffer;
|
const char *ptr = (char*)buffer;
|
||||||
|
|
||||||
if (dasizeof > LZWSIZE && count > LZWSIZE)
|
if (dasizeof > LZWSIZE)
|
||||||
{
|
|
||||||
if (count > LZWSIZE)
|
|
||||||
{
|
{
|
||||||
count *= dasizeof;
|
count *= dasizeof;
|
||||||
dasizeof = 1;
|
dasizeof = 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
uint32_t i = count;
|
|
||||||
count = dasizeof;
|
|
||||||
dasizeof = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bassert(dasizeof < sizeof(lzwrawbuf));
|
|
||||||
Bmemcpy(lzwrawbuf, ptr, (int32_t)dasizeof);
|
Bmemcpy(lzwrawbuf, ptr, (int32_t)dasizeof);
|
||||||
|
|
||||||
uint32_t k = dasizeof;
|
uint32_t k = dasizeof;
|
||||||
|
|
|
@ -55,10 +55,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
// increase by 3, because atomic GRP adds 1, and Shareware adds 2
|
// increase by 3, because atomic GRP adds 1, and Shareware adds 2
|
||||||
#ifdef LUNATIC
|
#ifdef LUNATIC
|
||||||
// Lunatic
|
// Lunatic
|
||||||
# define BYTEVERSION_JF 294
|
# define BYTEVERSION_JF 297
|
||||||
#else
|
#else
|
||||||
// Non-Lua build
|
// Non-Lua build
|
||||||
# define BYTEVERSION_JF 294
|
# define BYTEVERSION_JF 297
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define BYTEVERSION_13 27
|
//#define BYTEVERSION_13 27
|
||||||
|
|
Loading…
Reference in a new issue