Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-4218

Cannot add and update item at type of log with multi byte character in key.

    Details

    • Type: Incident report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.6, 1.8.7, 1.8.8
    • Fix Version/s: 2.0.11rc1, 2.2.2rc1, 2.3.0
    • Component/s: API (A)
    • Labels:
    • Environment:

      Description

      When item with multi byte character in key is created or updated ,Error messages display.
      I found that is equal to 'S_INVALID_KEY_FORMAT'(define).

      == Error messages ==


      Title: ERROR: Cannot add item
      Details: Error in item key: Invalid item key format.


      Title: ERROR: Cannot update item
      Details: Error in item key: Invalid item key format.


      Item Detail is below.

      == Item details ==


      Host: Zabbix server
      Type: Zabbix agent(active)
      Keys: log[/var/log/messages,'???',"UTF-8",100]
      Type of information: Log


      I found detail message at ./api/classes/class.citemkey.php in 319.
      End of key "]" is not judged in this function.I would.

      == class.citemkey.php ==


      104 private function parseKeyParameters(){
      .....
      140 // for every byte, starting after '['
      141 for($this->currentByte+; $this->currentByte < $this->keyByteCnt; $this->currentByte+) {
      142 switch($this->state){
      143 // initial state
      144 case 0:
      .....
      191 // all nestings are closed correctly
      192 if ($this->nestLevel == 0 && isset($this->key[$this->currentByte+1]) && $this->key[$this->currentByte+1] == ']' && !isset($this->key[$this->currentByte+2]))

      { 193 return; 194 }

      195
      .....
      315 break;
      316 }
      317 }
      318 $this->isValid = false;
      319 $this->error = S_INVALID_KEY_FORMAT;


      == Try to find a cause ==
      I consider to be caused by mb_strlen override strlen.
      Mb_strlen returns number not of byte but of character.It's too small than byte of key.
      "for loop"in 141 cannnot reach end of key "]".I would.

      Affecting Apache configration is found.
      But this param needs for JP package to work.

      1. cat /etc/httpd/conf.d/zabbix.conf

        php_value mbstring.func_overload 6


      == A provisional avoiding ==

      Modify class.citemkey.php
      57c57
      < $this->keyByteCnt = strlen($this->key);

      > $this->keyByteCnt = strlen(bin2hex($this->key)) / 2;

      Regards.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rebine Ryuji Ebine
              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: