Page MenuHomeFreeBSD

Compute the correct size of the string to move forward.
ClosedPublic

Authored by jhb on Sep 1 2020, 4:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 3, 6:32 AM
Unknown Object (File)
Fri, May 3, 6:32 AM
Unknown Object (File)
Fri, May 3, 6:30 AM
Unknown Object (File)
Fri, May 3, 12:38 AM
Unknown Object (File)
Mar 3 2024, 7:47 AM
Unknown Object (File)
Jan 30 2024, 8:34 AM
Unknown Object (File)
Dec 22 2023, 7:35 PM
Unknown Object (File)
Dec 20 2023, 1:20 AM
Subscribers

Details

Summary

Previously this was counting the amount of spare room at the start of
the buffer that the string needed to move forward and passing that as
the number of bytes to copy to memmove rather than the length of the
string to be copied.

In the strfmon test in the test suite this caused the memmove to
overflow the allocated buffer by one byte which CHERI caught.

Reported by: CHERI
Obtained from: CheriBSD

Test Plan
  • run the strfmon_test tests under CHERI and verify still works under plain riscv64

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Sep 1 2020, 4:37 PM
jhb created this revision.

Ironically, this appears to have been introduced in rS104963 where the commit log there claims it was fixing bad pointer arithmetic. I think perhaps the author there didn't realize the string was right justified?

This revision is now accepted and ready to land.Sep 1 2020, 6:05 PM