1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

core: fix integer overflow in calls to realloc (issue #809)

This commit is contained in:
Sébastien Helleu
2016-10-08 13:10:56 +02:00
parent 485aff59c4
commit 997f47f77a
2 changed files with 17 additions and 3 deletions
+5
View File
@@ -24,6 +24,7 @@
#endif
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
@@ -672,6 +673,8 @@ util_file_get_content (const char *filename)
while (!feof (f))
{
if (fp > SIZE_MAX - (1024 * sizeof (char)))
goto error;
buffer2 = (char *) realloc (buffer, (fp + (1024 * sizeof (char))));
if (!buffer2)
goto error;
@@ -681,6 +684,8 @@ util_file_get_content (const char *filename)
goto error;
fp += count;
}
if (fp > SIZE_MAX - sizeof (char))
goto error;
buffer2 = (char *) realloc (buffer, fp + sizeof (char));
if (!buffer2)
goto error;