|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [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: Fri Jul 19 04:01:28 2024 UTC