From 6eca133ee9985c298186cbe05f888082c30bf2d9 Mon Sep 17 00:00:00 2001 From: Sandro Santilli <strk@kbt.io> Date: Fri, 2 Jun 2017 09:34:32 +0200 Subject: [PATCH 03/29] Fix potential DOS in decompilers (CVS-2017-8782) Closes #70 --- util/read.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util/read.c b/util/read.c index 4c18307a..b4296959 100644 --- a/util/read.c +++ b/util/read.c @@ -247,6 +247,11 @@ char *readString(FILE *f) if(len >= buflen-2) { buf = (char *)realloc(buf, sizeof(char)*(buflen+256)); + if ( ! buf ) + { + fprintf(stderr, "failed reallocating %d bytes\n", buflen+256); + exit(-1); + } buflen += 256; p = buf+len; } @@ -350,6 +355,11 @@ char *readSizedString(FILE *f,int size) if(len >= buflen-2) { buf = (char *)realloc(buf, sizeof(char)*(buflen+256)); + if ( ! buf ) + { + fprintf(stderr, "failed reallocating %d bytes\n", buflen+256); + exit(-1); + } buflen += 256; p = buf+len; } -- 2.14.3