php.net |  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: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 5.6.27 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2016-10-29 13:30 UTC] cmb@php.net
Description:
------------
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:
---------------
<?php

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

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

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

dbase_open($filename, 0);


Expected result:
----------------
valgrind is happy

Actual result:
--------------
valgrind reports a memory leak

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-29 13:30 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-10-29 14:21 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=340790
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] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC