plausichecks fehlertext: check number of parameters before calling vsprintf

This commit is contained in:
KarpAlex
2022-10-05 14:07:29 +02:00
parent c31ab4874d
commit edd310351b
2 changed files with 18 additions and 2 deletions
@@ -78,7 +78,15 @@ class Plausichecks extends Auth_Controller
if (hasData($fehlerRes))
{
$fehlerText = getData($fehlerRes)[0]->fehlertext;
$fehlerText = isEmptyArray($fehlertext_params) ? $fehlerText : vsprintf($fehlerText, $fehlertext_params);
if (!isEmptyArray($fehlertext_params))
{
if (count($fehlertext_params) != substr_count($fehlerText, '%s'))
$this->terminateWithJsonError('Wrong number of parameters for Fehlertext, fehler_kurzbz ' . $fehler_kurzbz);
$fehlerText = vsprintf($fehlerText, $fehlertext_params);
}
if (isset($person_id)) $fehlerText .= "; person_id: $person_id";
if (isset($oe_kurzbz)) $fehlerText .= "; oe_kurzbz: $oe_kurzbz";
$issueTexts[$fehler_kurzbz][] = $fehlerText;
+9 -1
View File
@@ -236,7 +236,15 @@ class IssuesLib
if (hasData($fehlerRes))
{
$fehlertextVorlage = getData($fehlerRes)[0]->fehlertext;
$fehlertext = isEmptyArray($fehlertext_params) ? $fehlertextVorlage : vsprintf($fehlertextVorlage, $fehlertext_params);
$fehlertext = $fehlertextVorlage;
if (!isEmptyArray($fehlertext_params))
{
if (count($fehlertext_params) != substr_count($fehlertextVorlage, '%s'))
return error('Wrong number of parameters for Fehlertext, fehler_kurzbz ' . $fehlercode);
$fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params);
}
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);