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

httppoller, process_httptest, errbuf not initialized to empty string

    XMLWordPrintable

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 57 (Oct 2019)
    • Story Points:
      0.125

      Description

       

      Steps to reproduce:

      1. Create httptest with httpstep in web user interface
      2. Use an URL to which libcurl cannot connect - forcing a libcurl connect error result CURLE_COULDNT_CONNECT
      3. Increase log level for httppoller in zabbix server
      4. Watch zabbix server log output
      5. See error messages similar to the ones below
      6. See that zabbix fails to insert/update history data as the value is an invalid mysql string value

       

      Result:

      zabbix server log:

      2464:20190930:231915.712 End of process_httptests()
       2464:20190930:231915.712 query [txnlev:0] [select min(t.nextcheck) from httptest t,hosts h where t.hostid=h.hostid and mod(t.httptestid,2)=0 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.maintenance_status=0 or h.maintenance_type=0)]
       2465:20190930:231915.713 In substitute_simple_macros() data:'https://www.volkshotel.nl/en/'
       2465:20190930:231915.713 In substitute_simple_macros() data:EMPTY
       2465:20190930:231915.713 In substitute_simple_macros() data:'REPLACES'
       2465:20190930:231915.713 In substitute_simple_macros() data:'200'
       2465:20190930:231915.713 In substitute_simple_macros() data:EMPTY
       2465:20190930:231915.713 In http_substitute_variables() data:'https://www.REPLACED.nl/en/'
       2465:20190930:231915.713 End of http_substitute_variables() data:'https://www.volkshotel.nl/en/'
       2465:20190930:231915.713 In http_substitute_variables() data:''
       2465:20190930:231915.713 End of http_substitute_variables() data:''
       2465:20190930:231915.713 process_httptest() use step "httpshomepage"
       2465:20190930:231915.713 In http_substitute_variables() data:''
       2465:20190930:231915.713 End of http_substitute_variables() data:''
       2465:20190930:231915.713 process_httptest() go to URL "https://www.REPLACED.nl/en/"
       2464:20190930:231915.714 No httptests to process in get_minnextcheck.
       2464:20190930:231915.714 __zbx_zbx_setproctitle() title:'http poller #1 [got 0 values in 0.003067 sec, idle 5 sec]'
       2465:20190930:231915.717 cannot process step "httpshomepage" of web scenario "httpshomepagescenario" on host "REPLACED": Couldn't connect to server: ¨cÃ<99>.V
       2465:20190930:231915.718 query without transaction detected
       2465:20190930:231915.718 query [txnlev:0] [update httptest set nextcheck=1569878355+delay where httptestid=5]
       2465:20190930:231915.722 In process_test_data()
       2465:20190930:231915.722 query [txnlev:0] [select type,itemid from httptestitem where httptestid=5]
       2465:20190930:231915.723 End of process_test_data()
       2465:20190930:231915.723 End of process_httptest()
       2465:20190930:231915.723 End of process_httptests()
       2465:20190930:231915.723 query [txnlev:0] [select min(t.nextcheck) from httptest t,hosts h where t.hostid=h.hostid and mod(t.httptestid,2)=1 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.maintenance_status=0 or h.maintenance_type=0)]
      
      -------------------------
      
      2465:20190930:235816.420 query without transaction detected
       2465:20190930:235816.420 query [txnlev:0] [update httptest set nextcheck=1569880696+delay where httptestid=5]
       2465:20190930:235816.425 In process_test_data()
       2465:20190930:235816.425 query [txnlev:0] [select type,itemid from httptestitem where httptestid=5]
       2465:20190930:235816.427 End of process_test_data()
       2465:20190930:235816.427 End of process_httptest()
       2465:20190930:235816.427 End of process_httptests()
       2465:20190930:235816.427 query [txnlev:0] [select min(t.nextcheck) from httptest t,hosts h where t.hostid=h.hostid and mod(t.httptestid,2)=1 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.maintenance_status=0 or h.maintenance_type=0)]
       2465:20190930:235816.429 __zbx_zbx_setproctitle() title:'http poller #2 [got 1 values in 0.017610 sec, idle 5 sec]'
       2469:20190930:235816.498 [Z3005] query failed: [1366] Incorrect string value: '\xD8b\xC3\x99.V' for column 'value' at row 1 [insert into history_str (itemid,clock,ns,value) values (26814,1569880696,420686300,'Couldn\'t connect to server: ØbÃ<99>.V');
      ]
      

      ------------------------

       

      Notice random memory bytes/garbage being printed at line: 2465:20190930:231915.717

      Notice how the mysql insert fails at line 2469:20190930:235816.498 : err_str = zbx_dsprintf(err_str, "%s: %s", curl_easy_strerror(err), errbuf);

      Potentially could cause zabbix-server to crash.

       

      Cause:

      1. file ./src/zabbix_server/httppoller/httptest.c
      2. if curl_easy_perform fails, err_str is set in line 972 (checkout of git today)
      3. errbuf buffer is not initialized to an empty string
      4. libcurl does not set errbuf in case of a connection error (it seems)
      5. as a result errbuf is printed with random character/byte values
      6. the random bytes are printed in the log
      7. the random bytes cause the mysql insert to fail 

      Solution:

      1. do not rely/assume libcurl will set the value of errbuf, as their man page explains
      2. initialize errbuf to an empty string.

       

      zabbix-server-mysql 1:3.2.6-1+xenial

      a clone of the latest zabbix git repo shows that this bug is still present.

       

       

       

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              arimdjonoks Artjoms Rimdjonoks
              Reporter:
              av0 anonymous
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: