From bcec2fdcf5bf47ffbf70f3471d8e7e940d99162e Mon Sep 17 00:00:00 2001 From: Walter Doekes Date: Tue, 1 Sep 2020 10:03:20 +0200 Subject: [PATCH] Fix buffer overflow in screen output Reported/tested by @brettowe Closes #479 --- src/screen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/screen.cpp b/src/screen.cpp index 436bcdc1..bbf9cd2a 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -277,7 +277,7 @@ void ScreenPrinter::draw_scenario_screen() display_scenario->stats->GetStat(CStat::CPT_C_OutgoingCallCreated); if (creationMode == MODE_SERVER) { lines.push_back(" Port Total-time Total-calls Transport"); - snprintf(buf, 256, " %-5d %6lu.%02lu s %8llu %s", local_port, + snprintf(buf, bufsiz, " %-5d %6lu.%02lu s %8llu %s", local_port, clock_tick / 1000, (clock_tick % 1000) / 10, total_calls, TRANSPORT_TO_STRING(transport)); lines.push_back(buf); @@ -286,7 +286,7 @@ void ScreenPrinter::draw_scenario_screen() if (users >= 0) { lines.push_back(" Users (length) Port Total-time " "Total-calls Remote-host"); - snprintf(buf, 256, + snprintf(buf, bufsiz, " %d (%d ms) %-5d %6lu.%02lu s %8llu %s:%d(%s)", users, duration, local_port, clock_tick / 1000, (clock_tick % 1000) / 10, total_calls, remote_ip, @@ -296,7 +296,7 @@ void ScreenPrinter::draw_scenario_screen() lines.push_back(" Call rate (length) Port Total-time " "Total-calls Remote-host"); snprintf( - buf, 256, + buf, bufsiz, " %3.1f(%d ms)/%5.3fs %-5d %6lu.%02lu s %8llu %s:%d(%s)", rate, duration, (double)rate_period_ms / 1000.0, local_port, clock_tick / 1000, (clock_tick % 1000) / 10, total_calls,