]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Compute the correct size of the string to move forward.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 2 Sep 2020 20:04:26 +0000 (20:04 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Wed, 2 Sep 2020 20:04:26 +0000 (20:04 +0000)
commit1a4531bc98da1de16bed68ecba051d6bf3a4764f
tree0bd080da8dc1c179290ef5fbca59c145acaf60cc
parenta2d704d19f280341989c821cd7aaa0348b31bf01
Compute the correct size of the string to move forward.

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
Reviewed by: kevans
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26280
lib/libc/stdlib/strfmon.c