1
Fork 0

Applying Michael Samuel's patch to avoid buffer overflow while loading

the algorithm name from a dump file.
main
Fabiano C. Botelho 2013-04-15 23:42:21 -07:00
parent b8c5b54c9a
commit f9e5adacbd
1 changed files with 6 additions and 1 deletions

View File

@ -38,13 +38,18 @@ cmph_t *__cmph_load(FILE *f)
register size_t nbytes;
DEBUGP("Loading mphf\n");
while(1)
for(i = 0; i < BUFSIZ; i++)
{
size_t c = fread(ptr, (size_t)1, (size_t)1, f);
if (c != 1) return NULL;
if (*ptr == 0) break;
++ptr;
}
if(algo_name[i] != 0)
{
DEBUGP("Attempted buffer overflow while loading mph file\n");
return NULL;
}
for(i = 0; i < CMPH_COUNT; ++i)
{
if (strcmp(algo_name, cmph_names[i]) == 0)