Bug #79263 [Opn->Fbk]: finfo_buffer fails with "PHP Fatal error: Allowed memory size of"

From: Date: Tue, 06 Jul 2021 16:22:52 +0000
Subject: Bug #79263 [Opn->Fbk]: finfo_buffer fails with "PHP Fatal error: Allowed memory size of"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234838@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79263&edit=1 ID: 79263 Updated by: cmb@php.net Reported by: anestis at fraganestis dot eu Summary: finfo_buffer fails with "PHP Fatal error: Allowed memory size of" -Status: Open +Status: Feedback Type: Bug Package: Unknown/Other Function Operating System: Debian 9 PHP Version: 7.4.2 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > In any case, this is a bug in upstream libmagic, it needs to be > reported and fixed there before we can do anything about it. Has anybody reported that upstream[1]? [1] <http://darwinsys.com/file/> Previous Comments: ------------------------------------------------------------------------ [2020-06-12 07:47:56] magnar at myrtveit dot com I've created two scripts illustrating the problem with finfo_buffer: Memory usage of finfo_file: https://3v4l.org/M3YLG Memory usage of finfo_buffer: https://3v4l.org/LNNoV On a 16M file, finfo_file uses 20M memory. finfo_buffer, however, uses 244M! ------------------------------------------------------------------------ [2020-02-14 17:14:53] anestis at fraganestis dot eu The error is produced when I use the following sequence: 1) read the data from a temp file into a buffer 2) call finfo_buffer to get the mimetype 3) parse the buffer The error is not produced and everything works fine if the sequence is modified as follows: 1) call finfo_file on temp file to get the mimetype 2) read the data from the same temp file into a buffer 3) parse the buffer ------------------------------------------------------------------------ [2020-02-13 08:15:27] nikic@php.net This sounds similar to bug #78987. In any case, this is a bug in upstream libmagic, it needs to be reported and fixed there before we can do anything about it. ------------------------------------------------------------------------ [2020-02-13 05:15:01] anestis at fraganestis dot eu @requinix@php.net: It's a pdf file. Seems legit. The reader (foxit) opens it just fine. ------------------------------------------------------------------------ [2020-02-13 05:11:07] anestis at fraganestis dot eu @requinix@php.net: just over 17M (17318320 bytes). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79263 -- Edit this bug report at https://bugs.php.net/bug.php?id=79263&edit=1

« previous php.bugs (#234838) next »