extra checking on memory allocation sizes to prevent a class of overflow attacks

This commit is contained in:
Josh Coalson
2007-09-11 04:49:56 +00:00
parent 0221d87c89
commit 0f008d2e9e
26 changed files with 234 additions and 115 deletions

View File

@@ -22,6 +22,7 @@
#include "utils.h"
#include "FLAC/assert.h"
#include "share/alloc.h"
#include "share/utf8.h"
#include <ctype.h>
#include <stdarg.h>
@@ -57,7 +58,7 @@ char *local_strdup(const char *source)
void local_strcat(char **dest, const char *source)
{
unsigned ndest, nsource;
size_t ndest, nsource;
FLAC__ASSERT(0 != dest);
FLAC__ASSERT(0 != source);
@@ -68,7 +69,7 @@ void local_strcat(char **dest, const char *source)
if(nsource == 0)
return;
*dest = (char*)realloc(*dest, ndest + nsource + 1);
*dest = (char*)safe_realloc_add_3op_(*dest, ndest, /*+*/nsource, /*+*/1);
if(0 == *dest)
die("out of memory growing string");
strcpy((*dest)+ndest, source);