From: Ilia Alshanetsky Date: Mon, 8 Nov 2004 04:55:14 +0000 (+0000) Subject: MFH: Fixed possible crash on fstat() failure. X-Git-Tag: php-4.3.10RC1~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9a5843251c1025e0adedf5205fab9306a85ec8d;p=php MFH: Fixed possible crash on fstat() failure. --- diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c index c627d00b30..32a04ed918 100644 --- a/ext/fdf/fdf.c +++ b/ext/fdf/fdf.c @@ -867,7 +867,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'; @@ -885,7 +888,7 @@ PHP_FUNCTION(fdf_save_string) if(err != FDFErcOK) { FDF_FAILURE(err); } - +err: if(temp_filename) { unlink(temp_filename); efree(temp_filename);