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

Possible use of uninitialized variable when reporting elastic history backend error

XMLWordPrintable

    • Team A
    • Sprint 46, Nov 2018
    • 0.5

      ** CID 184231:  Error handling issues  (CHECKED_RETURN)
      /src/libs/zbxhistory/history_elastic.c: 485 in elastic_writer_flush()
      
      
      ________________________________________________________________________________________________________
      *** CID 184231:  Error handling issues  (CHECKED_RETURN)
      /src/libs/zbxhistory/history_elastic.c: 485 in elastic_writer_flush()
      479                                                             " message: %s", curl_page->errbuf);
      480                                     }
      481                                     else
      482                                     {
      483                                             long int        err;
      484     
      >>>     CID 184231:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "curl_easy_getinfo" without checking return value (as is done elsewhere 8 out of 10 times).
      485                                             curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &err);
      486                                             zabbix_log(LOG_LEVEL_ERR, "cannot send data to elasticsearch, HTTP error code:"
      487                                                             " %ld", err);
      488                                     }
      489                             }
      490                             else if (CURLE_OK != msg->data.result)
      
      ** CID 184229:  Error handling issues  (CHECKED_RETURN)
      /src/libs/zbxhistory/history_elastic.c: 200 in elastic_log_error()
      
      
      ________________________________________________________________________________________________________
      *** CID 184229:  Error handling issues  (CHECKED_RETURN)
      /src/libs/zbxhistory/history_elastic.c: 200 in elastic_log_error()
      194     static void     elastic_log_error(CURL *handle, CURLcode error, const char *errbuf)
      195     {
      196             long    http_code;
      197     
      198             if (CURLE_HTTP_RETURNED_ERROR == error)
      199             {
      >>>     CID 184229:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "curl_easy_getinfo" without checking return value (as is done elsewhere 8 out of 10 times).
      200                     curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &http_code);
      201     
      202                     if (0 != page_r.offset)
      203                     {
      204                             zabbix_log(LOG_LEVEL_ERR, "cannot get values from elasticsearch, HTTP error: %ld, message: %s",
      205                                             http_code, page_r.data);
      

      According to libcurl documentation curl_easy_getinfo with CURLINFO_RESPONSE_CODE:

      Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.

      Not sure if it's possible for it to return error in our setup, but better to handle it.

            MVekslers Michael Veksler
            wiper Andris Zeila
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: