Skip to content
Snippets Groups Projects
Commit a63f061b authored by Mario Speiß's avatar Mario Speiß Committed by Rémi Denis-Courmont
Browse files

ConfigLoadString loses the last character of strings


ConfigLoadString allocates memory for 'size' bytes and copys a NULL terminated
string to this buffer.
ConfigSaveString instead expects the buffer to be NULL terminated but:
 - the 'size' saved to the cache is the char count
 - the string is written without terminating NULL.

So obviously ConfigLoadString does not match the behaviour of ConfigSaveString.
It seems to me that the cached module configuration is not working at all due
to comparing the module file names within CacheFind - this should never have
found a match.

I think this would need some more testing.

Regards,
Mario

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent a2d768f7
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ error:
if (size > 0)
{
psz = malloc (size);
psz = malloc (size+1);
if (unlikely(psz == NULL))
goto error;
if (fread (psz, 1, size, file) != size)
......@@ -104,7 +104,7 @@ error:
free (psz);
goto error;
}
psz[size - 1] = '\0';
psz[size] = '\0';
}
*p = psz;
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment