From: Ilia Alshanetsky Date: Mon, 8 Nov 2004 04:54:27 +0000 (+0000) Subject: Fixed possible crash on fstat() failure. X-Git-Tag: RELEASE_0_2~727 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb16f5e815333a2e5e277820aa223b94bec7cf65;p=php 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);