From: Ilia Alshanetsky Date: Mon, 8 Nov 2004 04:54:58 +0000 (+0000) Subject: MFH: Fixed possible crash on fstat() failure. X-Git-Tag: php-5.0.3RC1~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa5fbd0a0d1701bf7a877c3719fead8b4bfe5dad;p=php MFH: Fixed possible crash on fstat() failure. --- diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c index e3568b199a..db3a88e6d7 100644 --- a/ext/fdf/fdf.c +++ b/ext/fdf/fdf.c @@ -871,7 +871,10 @@ PHP_FUNCTION(fdf_save_string) struct stat stat; char *buf; - fstat(fileno(fp), &stat); + if (fstat(fileno(fp), &stat) == -1) { + RETVAL_FALSE; + goto err; + } buf = emalloc(stat.st_size +1); fread(buf, stat.st_size, 1, fp); buf[stat.st_size] = '\0'; @@ -889,7 +892,7 @@ PHP_FUNCTION(fdf_save_string) if(err != FDFErcOK) { FDF_FAILURE(err); } - +err: if(temp_filename) { unlink(temp_filename); efree(temp_filename);