|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73414 Unsupported field types may cause dbase_open() to leak memory
Submitted: 2016-10-29 13:30 UTC Modified: 2016-10-29 14:26 UTC
From: Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 5.6.27 OS: *
Private report: No CVE-ID: None
 [2016-10-29 13:30 UTC]
If dbase_open() fails due to an unsupported field type, it leaks the
memory of the strdup()'d names of previous supported fields.

Test script:

$filename = __DIR__ . DIRECTORY_SEPARATOR . 'test.dbf';

$db = dbase_create($filename, [['foo', 'C', 1], ['bar', 'C', 1]]);

$file = fopen($filename, 'r+b');
fseek($file, 75); // offset of the type marker of the second field
fwrite($file, 'Y'); // 'Y' is unsupported

dbase_open($filename, 0);

Expected result:
valgrind is happy

Actual result:
valgrind reports a memory leak


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-29 13:30 UTC]
-Assigned To: +Assigned To: cmb
 [2016-10-29 14:21 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #73414: Unsupported field types may cause dbase_open() to leak memory

If reading the DBF header fails, we have to deallocate already allocated
field names.
 [2016-10-29 14:26 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 25 23:01:30 2024 UTC