mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Merge pull request #4890 from leiradel/master
Don't use more than 32 MB of the content data to compute the hash
This commit is contained in:
commit
601a260d47
@ -92,6 +92,10 @@
|
|||||||
#define CHEEVOS_JSON_KEY_MEM 0x0b8807e4U
|
#define CHEEVOS_JSON_KEY_MEM 0x0b8807e4U
|
||||||
#define CHEEVOS_JSON_KEY_FORMAT 0xb341208eU
|
#define CHEEVOS_JSON_KEY_FORMAT 0xb341208eU
|
||||||
|
|
||||||
|
#define CHEEVOS_SIX_MB ( 6 * 1024 * 1024)
|
||||||
|
#define CHEEVOS_EIGHT_MB ( 8 * 1024 * 1024)
|
||||||
|
#define CHEEVOS_SIZE_LIMIT (32 * 1024 * 1024)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
/* Don't change those, the values match the console IDs
|
/* Don't change those, the values match the console IDs
|
||||||
@ -2704,9 +2708,6 @@ static int cheevos_deactivate_unlocks(unsigned game_id, retro_time_t *timeout)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHEEVOS_SIX_MB (6 * 1024 * 1024)
|
|
||||||
#define CHEEVOS_EIGHT_MB (8 * 1024 * 1024)
|
|
||||||
|
|
||||||
static INLINE unsigned cheevos_next_power_of_2(unsigned n)
|
static INLINE unsigned cheevos_next_power_of_2(unsigned n)
|
||||||
{
|
{
|
||||||
n--;
|
n--;
|
||||||
@ -2736,6 +2737,11 @@ static size_t cheevos_eval_md5(
|
|||||||
if (info->size - offset < max_size)
|
if (info->size - offset < max_size)
|
||||||
max_size = info->size - offset;
|
max_size = info->size - offset;
|
||||||
|
|
||||||
|
#ifdef CHEEVOS_SIZE_LIMIT
|
||||||
|
if (max_size > CHEEVOS_SIZE_LIMIT)
|
||||||
|
max_size = CHEEVOS_SIZE_LIMIT;
|
||||||
|
#endif
|
||||||
|
|
||||||
MD5_Update(ctx, (void*)((uint8_t*)info->data + offset), max_size);
|
MD5_Update(ctx, (void*)((uint8_t*)info->data + offset), max_size);
|
||||||
return max_size;
|
return max_size;
|
||||||
}
|
}
|
||||||
@ -2746,8 +2752,22 @@ static size_t cheevos_eval_md5(
|
|||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
size = filestream_get_size(file);
|
||||||
|
|
||||||
|
if (max_size == 0)
|
||||||
|
max_size = size;
|
||||||
|
|
||||||
|
if (size - offset < max_size)
|
||||||
|
max_size = size - offset;
|
||||||
|
|
||||||
|
#ifdef CHEEVOS_SIZE_LIMIT
|
||||||
|
if (max_size > CHEEVOS_SIZE_LIMIT)
|
||||||
|
max_size = CHEEVOS_SIZE_LIMIT;
|
||||||
|
#endif
|
||||||
|
|
||||||
filestream_seek(file, offset, SEEK_SET);
|
filestream_seek(file, offset, SEEK_SET);
|
||||||
|
size = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -2755,7 +2775,7 @@ static size_t cheevos_eval_md5(
|
|||||||
ssize_t num_read;
|
ssize_t num_read;
|
||||||
size_t to_read = sizeof(buffer);
|
size_t to_read = sizeof(buffer);
|
||||||
|
|
||||||
if (max_size != 0 && to_read > max_size)
|
if (to_read > max_size)
|
||||||
to_read = max_size;
|
to_read = max_size;
|
||||||
|
|
||||||
num_read = filestream_read(file, (void*)buffer, to_read);
|
num_read = filestream_read(file, (void*)buffer, to_read);
|
||||||
|
@ -134,7 +134,7 @@ ACHIEVEMENTS
|
|||||||
|
|
||||||
#include "../libretro-common/formats/json/jsonsax.c"
|
#include "../libretro-common/formats/json/jsonsax.c"
|
||||||
#include "../network/net_http_special.c"
|
#include "../network/net_http_special.c"
|
||||||
#include "../tasks/task_cheevos.c"
|
#include "../cheevos/cheevos.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*============================================================
|
/*============================================================
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "../../core.h"
|
#include "../../core.h"
|
||||||
#include "../../gfx/video_driver.h"
|
#include "../../gfx/video_driver.h"
|
||||||
#include "../../managers/core_option_manager.h"
|
#include "../../managers/core_option_manager.h"
|
||||||
#include "../../tasks/task_cheevos.h"
|
#include "../../cheevos/cheevos.h"
|
||||||
#include "../../content.h"
|
#include "../../content.h"
|
||||||
|
|
||||||
#define BASIC_INFO "info"
|
#define BASIC_INFO "info"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user