Project

General

Profile

Actions

Bug #9860

closed

Illegal string offset 'config' in /usr/local/pkg/tinc.inc on line 83

Added by Viktor Gurov over 4 years ago. Updated over 4 years ago.

Status:
Resolved
Priority:
Normal
Category:
Tinc
Target version:
-
Start date:
10/30/2019
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Affected Version:
2.5.0
Affected Plus Version:
Affected Architecture:

Description

Crash report details:

PHP Errors:
[30-Oct-2019 08:46:07 Europe/Moscow] PHP Warning: Illegal string offset 'config' in /usr/local/pkg/tinc.inc on line 83
[30-Oct-2019 08:46:07 Europe/Moscow] PHP Warning: Invalid argument supplied for foreach() in /usr/local/pkg/tinc.inc on line 85

82 if (!is_array($config['installedpackages']['tinchosts']['config'])) {
83                 $config['installedpackages']['tinchosts']['config'] = array();
84         }
85         foreach ($config['installedpackages']['tinchosts']['config'] as $host) {

found this issue on
https://stackoverflow.com/questions/25886103/php-warning-illegal-string-offset-and-invalid-argument-supplied-for-foreach
https://stackoverflow.com/questions/9869150/illegal-string-offset-warning-php

pfSense 2.5.0.a.20191030.0002

Actions #1

Updated by Viktor Gurov over 4 years ago

got this errors when Tinc Hosts is empty

Actions #2

Updated by Jim Pingle over 4 years ago

Probably because that array isn't fully initialized before use. It needs to be initialized at each level, not just the deepest one. We have a convenient function to do that, which is safe to run even if the array does contain data already:

init_config_arr(array('installedpackages', 'tinchosts', 'config'));

It should do that instead of the if (!is_array( ... test, for example:

82 init_config_arr(array('installedpackages', 'tinchosts', 'config'));
83 foreach ($config['installedpackages']['tinchosts']['config'] as $host) {
Actions #4

Updated by Jim Pingle over 4 years ago

  • Status changed from New to Pull Request Review
Actions #5

Updated by Renato Botelho over 4 years ago

  • Status changed from Pull Request Review to Feedback
  • Assignee set to Renato Botelho
  • Target version set to 2.5.0

PR has been merged. Thanks!

Actions #6

Updated by Renato Botelho over 4 years ago

  • % Done changed from 0 to 100
Actions #7

Updated by Jim Pingle over 4 years ago

  • Target version deleted (2.5.0)
Actions #8

Updated by Viktor Gurov over 4 years ago

  • Status changed from Feedback to Resolved

tested on tinc 1.0.35_2

pfSense 2.5.0.a.20191113.1759

Resolved

Actions

Also available in: Atom PDF