[ZBX-15095] Possible use of uninitialized variable when reporting elastic history backend error Created: 2018 Oct 30  Updated: 2018 Nov 21  Resolved: 2018 Nov 16

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 3.4.14, 4.0.1, 4.2.0alpha1
Fix Version/s: 4.0.2rc1, 4.2.0alpha1, 4.2 (plan)

Type: Problem report Priority: Trivial
Reporter: Andris Zeila Assignee: Michael Veksler
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team A
Sprint: Sprint 46, Nov 2018
Story Points: 0.5

 Description   
** 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.



 Comments   
Comment by Michael Veksler [ 2018 Nov 16 ]

Available in:

  • 4.0.2rc1 r86982,r86985
  • 4.2.0alpha1 (trunk) r86983,r86986
Generated at Fri Mar 29 07:17:15 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.