Merge pull request #212 from f1rmb/fix_array_offset_checking

Fix getConfigItem() function
This commit is contained in:
Kim - DG9VH 2020-08-31 20:50:52 +02:00 committed by GitHub
commit 157274df45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,15 +168,21 @@ function getDMRId ($mmdvmconfigs) {
function getConfigItem($section, $key, $configs) {
// retrieves the corresponding config-entry within a [section]
$sectionpos = array_search("[" . $section . "]", $configs) + 1;
$len = count($configs);
while(startsWith($configs[$sectionpos],$key."=") === false && $sectionpos <= ($len) ) {
if (startsWith($configs[$sectionpos],"[")) {
return null;
}
$sectionpos = arraye_search("[" . $section . "]", $configs);
if ($sectionpos !== FALSE) {
$sectionpos++;
$len = count($configs);
while(($sectionpos < $len) && (startsWith($configs[$sectionpos],$key."=") === false) ) {
if (startsWith($configs[$sectionpos],"[")) {
return null;
}
$sectionpos++;
}
if ($sectionpos < $len) {
return substr($configs[$sectionpos], strlen($key) + 1);
}
}
return substr($configs[$sectionpos], strlen($key) + 1);
return null;
}
function getEnabled ($mode, $mmdvmconfigs) {