Package: release.debian.org Severity: normal User: release.debian....@packages.debian.org Usertags: unblock
Please unblock package collectd This is a request for a pre-approval. The package has not been uploaded to unstable yet. The new version fixes various important bugs causing segfaults or lockups in either collectd or related software. All patches are already applied upstream and will be part of the next upstream patch release (which didn't come out in time for the freeze, thus I extracted all important fixes). Here's a summary of the changes; a full debdiff is attached: collectd (5.4.1-6) unstable; urgency=medium * debian/patches: - Added bts770681_riemann_ack: upstream fix for the write_riemann plugin to avoid locking up a remote Riemann instance; thanks to Marc Fournier for reporting this (Closes: #770681). - Added bts747093_lvm_segfault: upstream fix for a segfault in the LVM plugin; thanks to Bernd Zeimetz and Marc Fournier for reporting this (Closes: #747093). - Added bts770683_curl_init: upstream fix for a segfault in plugins using libcurl caused by concurrent memory access; thanks to Marc Fournier for reporting this (Closes: #770683, cf. #735173). - Added bts750440_config_segfault: upstream fix for a segfault when including empty config files; thanks to Bernd Zeimetz and Marc Fournier for reporting this (Closes: #750440, #770685). - Added bts770688_snmp_memleak: upstream fix for a memory leak in the SNMP plugin; thanks to Marc Fournier for reporting this (Closes: #770688). - Added bts770690_java_jni_thread_detach: upstream fix for locking up the Java plugin by not properly detaching from the JVM in error conditions; thanks to Marc Fournier for reporting this (Closes: #770690). - Added bts770693_timestamps: upstream fix for handling internal timestamps; thanks to Marc Fournier for reporting this (Closes: #770693) - Added bts770694_loglevel: upstream fix to correct logging behavior when using an invalid log level; thanks to Marc Fournier for reporting this (Closes: #770694, #687067). -- Sebastian Harl <tok...@debian.org> Sun, 23 Nov 2014 15:27:15 +0100 unblock collectd/5.4.1-6 -- System Information: Debian Release: 6.0.10 APT prefers oldstable-updates APT policy: (500, 'oldstable-updates'), (500, 'oldstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-vserver-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash -- Sebastian "tokkee" Harl +++ GnuPG-ID: 0x2F1FFCC7 +++ http://tokkee.org/ Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin
diff -u collectd-5.4.1/debian/changelog collectd-5.4.1/debian/changelog --- collectd-5.4.1/debian/changelog +++ collectd-5.4.1/debian/changelog @@ -1,3 +1,32 @@ +collectd (5.4.1-6) unstable; urgency=medium + + * debian/patches: + - Added bts770681_riemann_ack: upstream fix for the write_riemann plugin + to avoid locking up a remote Riemann instance; thanks to Marc Fournier + for reporting this (Closes: #770681). + - Added bts747093_lvm_segfault: upstream fix for a segfault in the LVM + plugin; thanks to Bernd Zeimetz and Marc Fournier for reporting this + (Closes: #747093). + - Added bts770683_curl_init: upstream fix for a segfault in plugins using + libcurl caused by concurrent memory access; thanks to Marc Fournier for + reporting this (Closes: #770683, cf. #735173). + - Added bts750440_config_segfault: upstream fix for a segfault when + including empty config files; thanks to Bernd Zeimetz and Marc Fournier + for reporting this (Closes: #750440, #770685). + - Added bts770688_snmp_memleak: upstream fix for a memory leak in the + SNMP plugin; thanks to Marc Fournier for reporting this + (Closes: #770688). + - Added bts770690_java_jni_thread_detach: upstream fix for locking up the + Java plugin by not properly detaching from the JVM in error conditions; + thanks to Marc Fournier for reporting this (Closes: #770690). + - Added bts770693_timestamps: upstream fix for handling internal + timestamps; thanks to Marc Fournier for reporting this (Closes: #770693) + - Added bts770694_loglevel: upstream fix to correct logging behavior when + using an invalid log level; thanks to Marc Fournier for reporting this + (Closes: #770694, #687067). + + -- Sebastian Harl <tok...@debian.org> Sun, 23 Nov 2014 15:27:15 +0100 + collectd (5.4.1-5) unstable; urgency=medium * debian/rules: diff -u collectd-5.4.1/debian/patches/00list collectd-5.4.1/debian/patches/00list --- collectd-5.4.1/debian/patches/00list +++ collectd-5.4.1/debian/patches/00list @@ -6,0 +7,8 @@ +bts770681_riemann_ack.dpatch +bts747093_lvm_segfault.dpatch +bts770683_curl_init.dpatch +bts750440_config_segfault.dpatch +bts770688_snmp_memleak.dpatch +bts770690_java_jni_thread_detach.dpatch +bts770693_timestamps.dpatch +bts770694_loglevel.dpatch only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts747093_lvm_segfault.dpatch +++ collectd-5.4.1/debian/patches/bts747093_lvm_segfault.dpatch @@ -0,0 +1,29 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## +## DP: bts747093_lvm_segfault.dpatch by Jan Kundrát <jan.kund...@cesnet.cz> +## DP: +## DP: lvm: Fix segfault when there are no logical volumes. +## DP: +## DP: Upstream bug report: +## DP: https://github.com/collectd/collectd/issues/558 +## DP: +## DP: Upstream commit: +## DP: https://github.com/jktjkt/collectd/commit/40dde67 + +@DPATCH@ + +diff a/src/lvm.c b/src/lvm.c +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -53,6 +53,11 @@ static int vg_read(vg_t vg, char const *vg_name) + lvm_submit (vg_name, "free", lvm_vg_get_free_size(vg)); + + lvs = lvm_vg_list_lvs(vg); ++ if (!lvs) { ++ /* no VGs are defined, which is not an error per se */ ++ return (0); ++ } ++ + dm_list_iterate_items(lvl, lvs) { + lvm_submit(vg_name, lvm_lv_get_name(lvl->lv), lvm_lv_get_size(lvl->lv)); + } only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts750440_config_segfault.dpatch +++ collectd-5.4.1/debian/patches/bts750440_config_segfault.dpatch @@ -0,0 +1,41 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts750440_config_segfault.dpatch by Wilfried Goesgens <dotheb...@citadel.org> +## +## DP: Fixed a segfault when handling/including empty config files. +## DP: +## DP: Correctly handle the case of empty "children" nodes. +## DP: +## DP: Upstream bug report: +## DP: https://github.com/collectd/collectd/issues/638 +## DP: +## DP: Upstream commit: +## DP: https://github.com/dothebart/collectd/commit/2923883 + +@DPATCH@ + +diff a/src/configfile.c b/src/configfile.c +--- a/src/configfile.c ++++ b/src/configfile.c +@@ -414,6 +414,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, + + /* Resize the memory containing the children to be big enough to hold + * all children. */ ++ if (dst->children_num + src->children_num - 1 == 0) ++ { ++ dst->children_num = 0; ++ return (0); ++ } ++ + temp = (oconfig_item_t *) realloc (dst->children, + sizeof (oconfig_item_t) + * (dst->children_num + src->children_num - 1)); +@@ -514,7 +520,8 @@ static int cf_include_all (oconfig_item_t *root, int depth) + continue; + + /* Now replace the i'th child in `root' with `new'. */ +- cf_ci_replace_child (root, new, i); ++ if (cf_ci_replace_child (root, new, i) < 0) ++ return (-1); + + /* ... and go back to the new i'th child. */ + --i; only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770681_riemann_ack.dpatch +++ collectd-5.4.1/debian/patches/bts770681_riemann_ack.dpatch @@ -0,0 +1,171 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770681_riemann_ack.dpatch by John-John Tedro <udop...@spotify.com> +## +## DP: write_riemann plugin: Receive acknowledge message when using TCP. +## DP: +## DP: Not receiving an acknowledge message when communicating with riemann +## DP: over TCP will cause the riemann instance to eventually hang for +## DP: extended periods of time because of resource exhaustion. +## DP: +## DP: Upstream bug report: +## DP: https://github.com/collectd/collectd/pull/425 +## DP: +## DP: Upstream commit: +## DP: https://github.com/spotify/collectd/commit/78c0678 + +@DPATCH@ + +diff a/src/write_riemann.c b/src/write_riemann.c +--- a/src/write_riemann.c ++++ b/src/write_riemann.c +@@ -176,32 +176,30 @@ riemann_disconnect (struct riemann_host *host) + return (0); + } + +-static int +-riemann_send(struct riemann_host *host, Msg const *msg) ++static inline int ++riemann_send_msg(struct riemann_host *host, const Msg *msg) + { +- u_char *buffer; ++ int status = 0; ++ u_char *buffer = NULL; + size_t buffer_len; +- int status; +- +- pthread_mutex_lock (&host->lock); + + status = riemann_connect (host); ++ + if (status != 0) +- { +- pthread_mutex_unlock (&host->lock); + return status; +- } + + buffer_len = msg__get_packed_size(msg); ++ + if (host->use_tcp) + buffer_len += 4; + + buffer = malloc (buffer_len); ++ + if (buffer == NULL) { +- pthread_mutex_unlock (&host->lock); + ERROR ("write_riemann plugin: malloc failed."); + return ENOMEM; + } ++ + memset (buffer, 0, buffer_len); + + if (host->use_tcp) +@@ -216,26 +214,105 @@ riemann_send(struct riemann_host *host, Msg const *msg) + } + + status = (int) swrite (host->s, buffer, buffer_len); ++ + if (status != 0) + { + char errbuf[1024]; + +- riemann_disconnect (host); +- pthread_mutex_unlock (&host->lock); +- + ERROR ("write_riemann plugin: Sending to Riemann at %s:%s failed: %s", + (host->node != NULL) ? host->node : RIEMANN_HOST, + (host->service != NULL) ? host->service : RIEMANN_PORT, + sstrerror (errno, errbuf, sizeof (errbuf))); ++ + sfree (buffer); + return -1; + } + +- pthread_mutex_unlock (&host->lock); + sfree (buffer); + return 0; + } + ++static inline int ++riemann_recv_ack(struct riemann_host *host) ++{ ++ int status = 0; ++ Msg *msg = NULL; ++ uint32_t header; ++ ++ status = (int) sread (host->s, &header, 4); ++ ++ if (status != 0) ++ return -1; ++ ++ size_t size = ntohl(header); ++ ++ // Buffer on the stack since acknowledges are typically small. ++ u_char buffer[size]; ++ memset (buffer, 0, size); ++ ++ status = (int) sread (host->s, buffer, size); ++ ++ if (status != 0) ++ return status; ++ ++ msg = msg__unpack (NULL, size, buffer); ++ ++ if (msg == NULL) ++ return -1; ++ ++ if (!msg->ok) ++ { ++ ERROR ("write_riemann plugin: Sending to Riemann at %s:%s acknowledgement message reported error: %s", ++ (host->node != NULL) ? host->node : RIEMANN_HOST, ++ (host->service != NULL) ? host->service : RIEMANN_PORT, ++ msg->error); ++ ++ msg__free_unpacked(msg, NULL); ++ return -1; ++ } ++ ++ msg__free_unpacked (msg, NULL); ++ return 0; ++} ++ ++/** ++ * Function to send messages (Msg) to riemann. ++ * ++ * Acquires the host lock, disconnects on errors. ++ */ ++static int ++riemann_send(struct riemann_host *host, Msg const *msg) ++{ ++ int status = 0; ++ pthread_mutex_lock (&host->lock); ++ ++ status = riemann_send_msg(host, msg); ++ ++ if (status != 0) { ++ riemann_disconnect (host); ++ pthread_mutex_unlock (&host->lock); ++ return status; ++ } ++ ++ /* ++ * For TCP we need to receive message acknowledgemenent. ++ */ ++ if (host->use_tcp) ++ { ++ status = riemann_recv_ack(host); ++ ++ if (status != 0) ++ { ++ riemann_disconnect (host); ++ pthread_mutex_unlock (&host->lock); ++ return status; ++ } ++ } ++ ++ pthread_mutex_unlock (&host->lock); ++ return 0; ++} ++ + static int riemann_event_add_tag (Event *event, char const *tag) /* {{{ */ + { + return (strarray_add (&event->tags, &event->n_tags, tag)); only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770683_curl_init.dpatch +++ collectd-5.4.1/debian/patches/bts770683_curl_init.dpatch @@ -0,0 +1,95 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770683_curl_init.dpatch by Jeremy Katz <jer...@katzbox.net> +## +## DP: Call curl_global_init() in _init of plugins using curl. +## DP: +## DP: curl_global_init() or curl_easy_init() has to be called in the init +## DP: callback of plugins using curl while collectd still runs single +## DP: threaded. Else, collectd may crash with a segfault due to concurrent +## DP: memory access by curl. +## DP: +## DP: Upstream bug report: +## DP: https://github.com/collectd/collectd/issues/526 +## DP: +## DP: Upstream commits: +## DP: https://github.com/katzj/collectd/commit/401fa6e + +@DPATCH@ + +diff a/src/curl.c b/src/curl.c +--- a/src/curl.c ++++ b/src/curl.c +@@ -569,6 +569,7 @@ static int cc_init (void) /* {{{ */ + INFO ("curl plugin: No pages have been defined."); + return (-1); + } ++ curl_global_init (CURL_GLOBAL_SSL); + return (0); + } /* }}} int cc_init */ + +diff a/src/curl_json.c b/src/curl_json.c +--- a/src/curl_json.c ++++ b/src/curl_json.c +@@ -957,9 +957,18 @@ static int cj_read (user_data_t *ud) /* {{{ */ + return cj_perform (db); + } /* }}} int cj_read */ + ++static int cj_init (void) /* {{{ */ ++{ ++ /* Call this while collectd is still single-threaded to avoid ++ * initialization issues in libgcrypt. */ ++ curl_global_init (CURL_GLOBAL_SSL); ++ return (0); ++} /* }}} int cj_init */ ++ + void module_register (void) + { + plugin_register_complex_config ("curl_json", cj_config); ++ plugin_register_init ("curl_json", cj_init); + } /* void module_register */ + + /* vim: set sw=2 sts=2 et fdm=marker : */ +diff a/src/curl_xml.c b/src/curl_xml.c +--- a/src/curl_xml.c ++++ b/src/curl_xml.c +@@ -1033,9 +1033,18 @@ static int cx_config (oconfig_item_t *ci) /* {{{ */ + return (0); + } /* }}} int cx_config */ + ++static int cx_init (void) /* {{{ */ ++{ ++ /* Call this while collectd is still single-threaded to avoid ++ * initialization issues in libgcrypt. */ ++ curl_global_init (CURL_GLOBAL_SSL); ++ return (0); ++} /* }}} int cx_init */ ++ + void module_register (void) + { + plugin_register_complex_config ("curl_xml", cx_config); ++ plugin_register_init ("curl_xml", cx_init); + } /* void module_register */ + + /* vim: set sw=2 sts=2 et fdm=marker : */ +diff a/src/write_http.c b/src/write_http.c +--- a/src/write_http.c ++++ b/src/write_http.c +@@ -590,9 +590,18 @@ static int wh_config (oconfig_item_t *ci) /* {{{ */ + return (0); + } /* }}} int wh_config */ + ++static int wh_init (void) /* {{{ */ ++{ ++ /* Call this while collectd is still single-threaded to avoid ++ * initialization issues in libgcrypt. */ ++ curl_global_init (CURL_GLOBAL_SSL); ++ return (0); ++} /* }}} int wh_init */ ++ + void module_register (void) /* {{{ */ + { + plugin_register_complex_config ("write_http", wh_config); ++ plugin_register_init ("write_http", wh_init); + } /* }}} void module_register */ + + /* vim: set fdm=marker sw=8 ts=8 tw=78 et : */ only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770688_snmp_memleak.dpatch +++ collectd-5.4.1/debian/patches/bts770688_snmp_memleak.dpatch @@ -0,0 +1,53 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770688_snmp_memleak.dpatch by Pierre-Yves Ritschard <p...@spootnik.org> +## and Marc Fournier <marc.fourn...@camptocamp.com> +## +## DP: Let snmp_synch_response deal with PDU freeing +## DP: +## DP: When reading from tables, upon errors the PDUs sent are already +## DP: freed by snmp_synch_response since they are right after +## DP: snmp_send is called. +## DP: +## DP: This commit syncs collectd's approach with other occurences of +## DP: snmp_synch_response calls. +## DP: +## DP: There might be a few corner cases where we leak PDUs, but it +## DP: is unclear how to check for those since we would need to +## DP: have an indication that snmp_send was never called, which +## DP: as far as I can tell is not possible. +## DP: +## DP: The potential for failure in snmp_send is rather low and will +## DP: be easily spotted though, since when crafting invalid PDUs +## DP: snmp send will constantly fail and since valid configurations +## DP: can never leak memory. +## DP: +## DP: Upstream bug reports: +## DP: https://github.com/collectd/collectd/issues/610 +## DP: https://github.com/collectd/collectd/issues/804 + +@DPATCH@ + +diff --git a/src/snmp.c b/src/snmp.c +index ad81c89..7d340d1 100644 +--- a/src/snmp.c ++++ b/src/snmp.c +@@ -1316,6 +1316,8 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + snmp_free_pdu (res); + res = NULL; + ++ /* snmp_synch_response already freed our PDU */ ++ req = NULL; + sfree (errstr); + csnmp_host_close_session (host); + +@@ -1437,6 +1439,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + snmp_free_pdu (res); + res = NULL; + ++ if (req != NULL) ++ snmp_free_pdu (req); ++ req = NULL; ++ + if (status == 0) + csnmp_dispatch_table (host, data, instance_list_head, value_list_head); + only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770690_java_jni_thread_detach.dpatch +++ collectd-5.4.1/debian/patches/bts770690_java_jni_thread_detach.dpatch @@ -0,0 +1,205 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770690_java_jni_thread_detach.dpatch by Florian Forster <o...@google.com> +## +## DP: java plugin: Make sure cjni_thread_detach() is called on all paths. +## DP: Each call to cjni_thread_attach() much be accompanied by a call to +## DP: cjni_thread_detach(). Some error handling cases were missing the call, +## DP: potentially locking the plugin up. +## DP: +## DP: Also ensure that cjni_thread_detach() does not hide the status of other +## DP: operations. +## DP: +## DP: Upstream commit: +## DP: https://github.com/collectd/collectd/commit/513a5ca + +@DPATCH@ + +diff a/src/java.c b/src/java.c +--- a/src/java.c ++++ b/src/java.c +@@ -2115,7 +2115,7 @@ static int cjni_thread_detach (void) /* {{{ */ + cjni_env->jvm_env = NULL; + + return (0); +-} /* }}} JNIEnv *cjni_thread_attach */ ++} /* }}} int cjni_thread_detach */ + + static int cjni_config_add_jvm_arg (oconfig_item_t *ci) /* {{{ */ + { +@@ -2468,7 +2468,6 @@ static int cjni_read (user_data_t *ud) /* {{{ */ + { + JNIEnv *jvm_env; + cjni_callback_info_t *cbi; +- int status; + int ret_status; + + if (jvm == NULL) +@@ -2492,13 +2491,7 @@ static int cjni_read (user_data_t *ud) /* {{{ */ + ret_status = (*jvm_env)->CallIntMethod (jvm_env, cbi->object, + cbi->method); + +- status = cjni_thread_detach (); +- if (status != 0) +- { +- ERROR ("java plugin: cjni_read: cjni_thread_detach failed."); +- return (-1); +- } +- ++ cjni_thread_detach (); + return (ret_status); + } /* }}} int cjni_read */ + +@@ -2509,7 +2502,6 @@ static int cjni_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */ + JNIEnv *jvm_env; + cjni_callback_info_t *cbi; + jobject vl_java; +- int status; + int ret_status; + + if (jvm == NULL) +@@ -2534,6 +2526,7 @@ static int cjni_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */ + if (vl_java == NULL) + { + ERROR ("java plugin: cjni_write: ctoj_value_list failed."); ++ cjni_thread_detach (); + return (-1); + } + +@@ -2542,13 +2535,7 @@ static int cjni_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */ + + (*jvm_env)->DeleteLocalRef (jvm_env, vl_java); + +- status = cjni_thread_detach (); +- if (status != 0) +- { +- ERROR ("java plugin: cjni_write: cjni_thread_detach failed."); +- return (-1); +- } +- ++ cjni_thread_detach (); + return (ret_status); + } /* }}} int cjni_write */ + +@@ -2560,7 +2547,6 @@ static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */ + cjni_callback_info_t *cbi; + jobject o_timeout; + jobject o_identifier; +- int status; + int ret_status; + + if (jvm == NULL) +@@ -2587,6 +2573,7 @@ static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */ + { + ERROR ("java plugin: cjni_flush: Converting double " + "to Number object failed."); ++ cjni_thread_detach (); + return (-1); + } + +@@ -2598,6 +2585,7 @@ static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */ + { + (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout); + ERROR ("java plugin: cjni_flush: NewStringUTF failed."); ++ cjni_thread_detach (); + return (-1); + } + } +@@ -2608,13 +2596,7 @@ static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */ + (*jvm_env)->DeleteLocalRef (jvm_env, o_identifier); + (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout); + +- status = cjni_thread_detach (); +- if (status != 0) +- { +- ERROR ("java plugin: cjni_flush: cjni_thread_detach failed."); +- return (-1); +- } +- ++ cjni_thread_detach (); + return (ret_status); + } /* }}} int cjni_flush */ + +@@ -2640,7 +2622,10 @@ static void cjni_log (int severity, const char *message, /* {{{ */ + + o_message = (*jvm_env)->NewStringUTF (jvm_env, message); + if (o_message == NULL) ++ { ++ cjni_thread_detach (); + return; ++ } + + (*jvm_env)->CallVoidMethod (jvm_env, + cbi->object, cbi->method, (jint) severity, o_message); +@@ -2658,7 +2643,6 @@ static int cjni_notification (const notification_t *n, /* {{{ */ + JNIEnv *jvm_env; + cjni_callback_info_t *cbi; + jobject o_notification; +- int status; + int ret_status; + + if (jvm == NULL) +@@ -2683,6 +2667,7 @@ static int cjni_notification (const notification_t *n, /* {{{ */ + if (o_notification == NULL) + { + ERROR ("java plugin: cjni_notification: ctoj_notification failed."); ++ cjni_thread_detach (); + return (-1); + } + +@@ -2691,13 +2676,7 @@ static int cjni_notification (const notification_t *n, /* {{{ */ + + (*jvm_env)->DeleteLocalRef (jvm_env, o_notification); + +- status = cjni_thread_detach (); +- if (status != 0) +- { +- ERROR ("java plugin: cjni_read: cjni_thread_detach failed."); +- return (-1); +- } +- ++ cjni_thread_detach (); + return (ret_status); + } /* }}} int cjni_notification */ + +@@ -2725,24 +2704,20 @@ static int cjni_match_target_create (const oconfig_item_t *ci, /* {{{ */ + (*jvm_env)->DeleteLocalRef (jvm_env, cbi_ret->object); \ + } \ + free (cbi_ret); \ +- if (jvm_env != NULL) { \ +- if (o_ci != NULL) \ +- (*jvm_env)->DeleteLocalRef (jvm_env, o_ci); \ +- cjni_thread_detach (); \ +- } \ ++ if (o_ci != NULL) \ ++ (*jvm_env)->DeleteLocalRef (jvm_env, o_ci); \ ++ cjni_thread_detach (); \ + return (status) + + if (jvm == NULL) + { + ERROR ("java plugin: cjni_read: jvm == NULL"); +- BAIL_OUT (-1); ++ return (-1); + } + + jvm_env = cjni_thread_attach (); + if (jvm_env == NULL) +- { +- BAIL_OUT (-1); +- } ++ return (-1); + + /* Find out whether to create a match or a target. */ + if (strcasecmp ("Match", ci->key) == 0) +@@ -2936,10 +2911,7 @@ static int cjni_match_target_invoke (const data_set_t *ds, /* {{{ */ + } + } /* if (cbi->type == CB_TYPE_TARGET) */ + +- status = cjni_thread_detach (); +- if (status != 0) +- ERROR ("java plugin: cjni_read: cjni_thread_detach failed."); +- ++ cjni_thread_detach (); + return (ret_status); + } /* }}} int cjni_match_target_invoke */ + only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770693_timestamps.dpatch +++ collectd-5.4.1/debian/patches/bts770693_timestamps.dpatch @@ -0,0 +1,124 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770693_timestamps.dpatch +## +## DP: Fixed handling of timestamps in notifications. +## DP: +## DP: Starting with collectd 5, timestamps use nano-second resolution rather +## DP: than seconds. Notitications did not handle that correctly, leading to +## DP: invalid time-stamps and potentially invalid memory access. +## DP: +## DP: Upstream commits: +## DP: https://github.com/collectd/collectd/commit/... +## DP: d571f4645593c16a26a98aa635b1952286089266 by Justin Burnham <jburn...@mediatemple.net> +## DP: 43fcfd6a48b506b03114dd9637caf8fc211b47db by Adrian Miron <adrian.miron...@gmail.com> +## DP: ac78faa99d4b34c78a7bca741430c06c56e6f32c by Manuel Luis Sanmartín Rozada <manuel.l...@gmail.com> +## DP: f5c294b7355cee34df44b1c5b8ac3ef7b85664cd by Manuel Luis Sanmartín Rozada <manuel.l...@gmail.com> +## DP: 7d1d59fb064f2a9adfba50d3ea5c39ebc6bebd3c by Manuel Luis Sanmartín Rozada <manuel.l...@gmail.com> +## DP: 07e4683f7f985668641d79137b64d148bc18ba8a by Manuel Luis Sanmartín Rozada <manuel.l...@gmail.com> +## DP: 524b85687dbbd4cc2bbb650caf300162dcd16e96 by Marc Fournier <marc.fourn...@camptocamp.com> + +@DPATCH@ + +diff a/src/exec.c b/src/exec.c +--- a/src/exec.c ++++ b/src/exec.c +@@ -744,8 +744,8 @@ static void *exec_notification_one (void *arg) /* {{{ */ + + fprintf (fh, + "Severity: %s\n" +- "Time: %.3f\n", +- severity, CDTIME_T_TO_DOUBLE (n->time)); ++ "Time: %u\n", ++ severity, (unsigned int)CDTIME_T_TO_TIME_T(n->time)); + + /* Print the optional fields */ + if (strlen (n->host) > 0) +diff a/src/java.c b/src/java.c +--- a/src/java.c ++++ b/src/java.c +@@ -906,7 +906,7 @@ static jobject ctoj_notification (JNIEnv *jvm_env, /* {{{ */ + #undef SET_STRING + + /* Set the `time' member. Java stores time in milliseconds. */ +- status = ctoj_long (jvm_env, ((jlong) n->time) * ((jlong) 1000), ++ status = ctoj_long (jvm_env, (jlong) CDTIME_T_TO_MS (n->time), + c_notification, o_notification, "setTime"); + if (status != 0) + { +@@ -1306,7 +1306,7 @@ static int jtoc_notification (JNIEnv *jvm_env, notification_t *n, /* {{{ */ + return (-1); + } + /* Java measures time in milliseconds. */ +- n->time = (time_t) (tmp_long / ((jlong) 1000)); ++ n->time = MS_TO_CDTIME_T(tmp_long); + + status = jtoc_int (jvm_env, &tmp_int, + class_ptr, object_ptr, "getSeverity"); + +diff a/src/pyvalues.c b/src/pyvalues.c +--- a/src/pyvalues.c ++++ b/src/pyvalues.c +@@ -767,7 +771,7 @@ static void Values_dealloc(PyObject *self) { + } + + static PyMemberDef Values_members[] = { +- {"interval", T_INT, offsetof(Values, interval), 0, interval_doc}, ++ {"interval", T_DOUBLE, offsetof(Values, interval), 0, interval_doc}, + {"values", T_OBJECT_EX, offsetof(Values, values), 0, values_doc}, + {"meta", T_OBJECT_EX, offsetof(Values, meta), 0, meta_doc}, + {NULL} +diff a/src/threshold.c b/src/threshold.c +--- a/src/threshold.c ++++ b/src/threshold.c +@@ -942,6 +942,7 @@ static int ut_missing (const value_list_t *vl, + cdtime_t missing_time; + char identifier[6 * DATA_MAX_NAME_LEN]; + notification_t n; ++ cdtime_t now; + + if (threshold_tree == NULL) + return (0); +@@ -951,13 +952,15 @@ static int ut_missing (const value_list_t *vl, + if ((th == NULL) || ((th->flags & UT_FLAG_INTERESTING) == 0)) + return (0); + +- missing_time = cdtime () - vl->time; ++ now = cdtime (); ++ missing_time = now - vl->time; + FORMAT_VL (identifier, sizeof (identifier), vl); + + NOTIFICATION_INIT_VL (&n, vl); + ssnprintf (n.message, sizeof (n.message), + "%s has not been updated for %.3f seconds.", + identifier, CDTIME_T_TO_DOUBLE (missing_time)); ++ n.time = now; + + plugin_dispatch_notification (&n); + +diff a/src/utils_cmd_putnotif.c b/src/utils_cmd_putnotif.c +--- a/src/utils_cmd_putnotif.c ++++ b/src/utils_cmd_putnotif.c +@@ -49,13 +49,18 @@ static int set_option_severity (notification_t *n, const char *value) + + static int set_option_time (notification_t *n, const char *value) + { +- time_t tmp; +- +- tmp = (time_t) atoi (value); +- if (tmp <= 0) ++ char *endptr = NULL; ++ double tmp; ++ ++ errno = 0; ++ tmp = strtod (value, &endptr); ++ if ((errno != 0) /* Overflow */ ++ || (endptr == value) /* Invalid string */ ++ || (endptr == NULL) /* This should not happen */ ++ || (*endptr != 0)) /* Trailing chars */ + return (-1); + +- n->time = tmp; ++ n->time = DOUBLE_TO_CDTIME_T (tmp); + + return (0); + } /* int set_option_time */ only in patch2: unchanged: --- collectd-5.4.1.orig/debian/patches/bts770694_loglevel.dpatch +++ collectd-5.4.1/debian/patches/bts770694_loglevel.dpatch @@ -0,0 +1,49 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770694_loglevel.dpatch +## +## DP: Make sure not to disable logging on invalid log levels. +## DP: +## DP: Debug logging is not compiled into the Debian packages. Make sure to +## DP: fall back to INFO and report and error rather than silently dropping +## DP: all further log messages. +## DP: +## DP: Upstream bug report: +## DP: https://github.com/collectd/collectd/issues/636 +## DP: +## DP: Upstream commits: +## DP: https://github.com/dothebart/collectd/commit/84c3805 +## DP: https://github.com/collectd/collectd/commit/cb4ea71 + +@DPATCH@ + +diff a/src/logfile.c b/src/logfile.c +--- a/src/logfile.c ++++ b/src/logfile.c +@@ -54,7 +54,11 @@ static int logfile_config (const char *key, const char *value) + { + if (0 == strcasecmp (key, "LogLevel")) { + log_level = parse_log_severity(value); +- if (log_level == -1) return 1; /* to keep previous behaviour */ ++ if (log_level < 0) { ++ log_level = LOG_INFO; ++ ERROR ("logfile: invalid loglevel [%s] defaulting to 'info'", value); ++ return (1); ++ } + } + else if (0 == strcasecmp (key, "File")) { + sfree (log_file); +diff a/src/syslog.c b/src/syslog.c +--- a/src/syslog.c ++++ b/src/syslog.c +@@ -48,7 +48,11 @@ static int sl_config (const char *key, const char *value) + { + log_level = parse_log_severity (value); + if (log_level < 0) ++ { ++ log_level = LOG_INFO; ++ ERROR ("syslog: invalid loglevel [%s] defaulting to 'info'", value); + return (1); ++ } + } + else if (strcasecmp (key, "NotifyLevel") == 0) + {
signature.asc
Description: Digital signature