Skip to content

Commit e1460af

Browse files
committed
Merged PR 147834: Fixing RL.exe buffer too small AV.
Fixing RL.exe buffer too small AV. While updating the cmd title we can buffer overflow. Fixed that by breaking the loop if we exceeding the buffer.
2 parents 15643c7 + dba723b commit e1460af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bin/rl/rl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4620,7 +4620,13 @@ UpdateTitleStatus()
46204620
// start at 1: skip primary thread 0 (unless we decide to let it do real work)
46214621
for (i = 1; i <= NumberOfThreads; i++) {
46224622
ThreadInfo[i].GetCurrentTest(tempBuf);
4623-
s += sprintf_s(s, REMAININGARRAYLEN(TitleStatus, s), "; %s", tempBuf);
4623+
size_t remainingCount = REMAININGARRAYLEN(TitleStatus, s);
4624+
size_t testLen = strnlen_s(tempBuf, BUFFER_SIZE);
4625+
// Accounting for formatting string and endofbuffer char.
4626+
if ((testLen + 3) >= remainingCount) {
4627+
break;
4628+
}
4629+
s += sprintf_s(s, remainingCount, "; %s", tempBuf);
46244630
}
46254631

46264632
LeaveCriticalSection(&csTitleBar);

0 commit comments

Comments
 (0)