#35756 [Opn->Bgs]: ecalloc in fgets() does't not check its return value
| From: | wez@php.net | Date: | Wed, 21 Dec 2005 07:50:24 +0000 |
| Subject: | #35756 [Opn->Bgs]: ecalloc in fgets() does't not check its return value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90777@lists.php.net to get a copy of this message | ||
ID: 35756
Updated by: wez@php.net
Reported By: sqchen at citiz dot net
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: redhat 7.3
PHP Version: 5.1.1
New Comment:
ecalloc, emalloc, erealloc and friends will never return NULL.
Previous Comments:
------------------------------------------------------------------------
[2005-12-21 03:39:46] sqchen at citiz dot net
Description:
------------
file ext/standard/file.c
line 1028
buf = ecalloc(len + 1, sizeof(char));
if (php_stream_get_line(stream, buf, len, &line_len) == NULL) {
goto exit_failed;
}
here doesn't check the availablity of 'buf', so if ecalloc doesn't
calloc a memory, it will return NULL, it will cause some problem
Reproduce code:
---------------
$fp=fopen("1.txt", "r");
fgets($fp, 2147483640);
on some platform, when ecalloc failed, it will return NULL, so
segmentation fault will prompt.
the same as fread function
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35756&edit=1