Project

General

Profile

Actions

Bug #12749

closed

Uninitialized array in ``array_remove_duplicates()``

Added by Viktor Gurov almost 3 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Viktor Gurov
Category:
DHCP (IPv6)
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
22.05
Release Notes:
Default
Affected Version:
2.5.2
Affected Architecture:

Description

https://github.com/pfsense/pfsense/blob/master/src/etc/inc/util.inc#L3322-L3333:

function array_remove_duplicate($array, $field) {
    foreach ($array as $sub) {
        if (isset($sub[$field])) {
            $cmp[] = $sub[$field];
        }
    }
    $unique = array_unique(array_reverse($cmp, true));
    foreach ($unique as $k => $rien) {
        $new[] = $array[$k];
    }
    return $new;
}

$cmp is not initialized with an empty array, and if all conditions are failed, $cmp == null

see https://forum.netgate.com/topic/169564/with-2-6rc-warning-array_reverse-expects-parameter-1-to-be-array-null-given

Actions

Also available in: Atom PDF