diff --git a/src/vt/group/collective/group_info_collective.cc b/src/vt/group/collective/group_info_collective.cc index 7c7075eb67..2ded4cc4ef 100644 --- a/src/vt/group/collective/group_info_collective.cc +++ b/src/vt/group/collective/group_info_collective.cc @@ -696,11 +696,12 @@ void InfoColl::finalize() { if (in_phase_two_ && send_down_finished_ == send_down_) { if (!vt_check_enabled(production_build)) { - char buf[256]; + constexpr int max_buffer_length = 256; + char buf[max_buffer_length]; buf[0] = '\0'; int cur = 0; for (auto&& elm : collective_->span_children_) { - cur += sprintf(buf + cur, "%d,", elm); + cur += snprintf(buf + cur, max_buffer_length - cur, "%d,", elm); } auto const& num_children = collective_->span_children_.size(); diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 7d73260004..51ace6b1c9 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -249,9 +249,10 @@ bool Runtime::hasSchedRun() const { void Runtime::pauseForDebugger() { if (theConfig()->vt_pause) { - char node_str[256]; + constexpr int max_buffer_length = 256; + char node_str[max_buffer_length]; auto node = vt::theContext() ? vt::theContext()->getNode() : -1; - sprintf(node_str, "prog-%d.pid", node); + snprintf(node_str, max_buffer_length, "prog-%d.pid", node); auto const pid = getpid(); FILE* f = fopen(node_str, "w+"); fprintf(f, "%d", pid);