Repository: qpid-dispatch Updated Branches: refs/heads/master 1a3775066 -> fcc370e66
DISPATCH-601 - Fixed a use-of-uninitialized-data defect found by Valgrind. Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/f27b0107 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/f27b0107 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/f27b0107 Branch: refs/heads/master Commit: f27b0107858f0a384ce19789ca97ec83c8d78804 Parents: 1a37750 Author: Ted Ross <[email protected]> Authored: Wed Jan 4 08:06:41 2017 -0500 Committer: Ted Ross <[email protected]> Committed: Wed Jan 4 08:06:41 2017 -0500 ---------------------------------------------------------------------- src/router_core/terminus.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f27b0107/src/router_core/terminus.c ---------------------------------------------------------------------- diff --git a/src/router_core/terminus.c b/src/router_core/terminus.c index 1587047..abd6a7b 100644 --- a/src/router_core/terminus.c +++ b/src/router_core/terminus.c @@ -187,26 +187,29 @@ qd_iterator_t *qdr_terminus_dnp_address(qdr_terminus_t *term) void qdr_terminus_set_dnp_address_iterator(qdr_terminus_t *term, qd_iterator_t *iter) { - char buffer[1000]; + char buffer[1001]; char *text = buffer; bool on_heap = false; pn_data_t *old = term->properties; + size_t len; if (!old) return; - if (qd_iterator_length(iter) < 1000) - qd_iterator_ncopy(iter, (unsigned char*) text, 1000); - else { + if (qd_iterator_length(iter) < 1000) { + len = qd_iterator_ncopy(iter, (unsigned char*) text, 1000); + text[len] = '\0'; + } else { text = (char*) qd_iterator_copy(iter); on_heap = true; + len = strlen(text); } pn_data_t *new = pn_data(pn_data_size(old)); pn_data_put_map(new); pn_data_enter(new); pn_data_put_symbol(new, pn_bytes(strlen(QD_DYNAMIC_NODE_PROPERTY_ADDRESS), QD_DYNAMIC_NODE_PROPERTY_ADDRESS)); - pn_data_put_string(new, pn_bytes(strlen(text), text)); + pn_data_put_string(new, pn_bytes(len, text)); pn_data_exit(new); term->properties = new; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
