php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63315 BitSet::fromArray modifies original array value if a non-integer is supplied
Submitted: 2012-10-19 18:21 UTC Modified: 2023-05-25 06:31 UTC
From: willfitch@php.net Assigned: remi (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS: Linux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: willfitch@php.net
New email:
PHP Version: OS:

 

 [2012-10-19 18:21 UTC] willfitch@php.net
Description:
------------
When passing an array to BitSet::fromArray, the original array is modified when 
any of the values in the array are non-long.

Test script:
---------------
<?php

$arr = array(5, 6, '7');
var_dump($arr);
BitSet::fromArray($arr);
var_dump($arr);

?>

Expected result:
----------------
array(3) {
  [0]=>
  int(5)
  [1]=>
  int(6)
  [2]=>
  string(1) "7"
}

Actual result:
--------------
array(3) {
  [0]=>
  int(5)
  [1]=>
  int(6)
  [2]=>
  int(7)
}

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-19 18:21 UTC] willfitch@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: willfitch
 [2017-10-24 03:26 UTC] kalle@php.net
-Status: Verified +Status: Assigned
 [2020-09-22 15:30 UTC] cmb@php.net
The problem is that the array elements are convert_to_long(), what
modifies the zvals in the array.  As a quick fix, separating the
array in zpp() should solve that.
 [2020-12-23 14:10 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #63315: BitSet::fromArray may modify original array value
On GitHub:  https://github.com/php/pecl-numbers-bitset/pull/13
Patch:      https://github.com/php/pecl-numbers-bitset/pull/13.patch
 [2023-05-24 14:00 UTC] git@php.net
Automatic comment on behalf of cmb69 (author) and remicollet (committer)
Revision: https://github.com/php/pecl-numbers-bitset/commit/11bad9e1ffe0c37fd47e40505eea80e6b98c3650
Log: Fix #63315: BitSet::fromArray may modify original array value
 [2023-05-24 14:00 UTC] git@php.net
-Status: Assigned +Status: Closed
 [2023-05-25 06:31 UTC] remi@php.net
-Package: Bitset +Package: *General Issues -Assigned To: willfitch +Assigned To: remi
 [2023-05-25 06:31 UTC] remi@php.net
Fixed upstream (will be in 3.1.0)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC