Skip to content

Commit bcec2fd

Browse files
committed
Fix buffer overflow in screen output
Reported/tested by @brettowe Closes #479
1 parent 5e4d725 commit bcec2fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/screen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void ScreenPrinter::draw_scenario_screen()
277277
display_scenario->stats->GetStat(CStat::CPT_C_OutgoingCallCreated);
278278
if (creationMode == MODE_SERVER) {
279279
lines.push_back(" Port Total-time Total-calls Transport");
280-
snprintf(buf, 256, " %-5d %6lu.%02lu s %8llu %s", local_port,
280+
snprintf(buf, bufsiz, " %-5d %6lu.%02lu s %8llu %s", local_port,
281281
clock_tick / 1000, (clock_tick % 1000) / 10, total_calls,
282282
TRANSPORT_TO_STRING(transport));
283283
lines.push_back(buf);
@@ -286,7 +286,7 @@ void ScreenPrinter::draw_scenario_screen()
286286
if (users >= 0) {
287287
lines.push_back(" Users (length) Port Total-time "
288288
"Total-calls Remote-host");
289-
snprintf(buf, 256,
289+
snprintf(buf, bufsiz,
290290
" %d (%d ms) %-5d %6lu.%02lu s %8llu %s:%d(%s)",
291291
users, duration, local_port, clock_tick / 1000,
292292
(clock_tick % 1000) / 10, total_calls, remote_ip,
@@ -296,7 +296,7 @@ void ScreenPrinter::draw_scenario_screen()
296296
lines.push_back(" Call rate (length) Port Total-time "
297297
"Total-calls Remote-host");
298298
snprintf(
299-
buf, 256,
299+
buf, bufsiz,
300300
" %3.1f(%d ms)/%5.3fs %-5d %6lu.%02lu s %8llu %s:%d(%s)",
301301
rate, duration, (double)rate_period_ms / 1000.0, local_port,
302302
clock_tick / 1000, (clock_tick % 1000) / 10, total_calls,

0 commit comments

Comments
 (0)