]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r343479: Fix potential buffer overflow and undefined behavior.
authorStefan Eßer <se@FreeBSD.org>
Sat, 9 Feb 2019 14:21:29 +0000 (14:21 +0000)
committerStefan Eßer <se@FreeBSD.org>
Sat, 9 Feb 2019 14:21:29 +0000 (14:21 +0000)
commit4af3ade922874be16a68ffddd7c5413d544a2040
tree4c215731834b02c0186464b5edf440b3c01f80e1
parent2a0ed2845cdc831346d5ff48b055216ae3593a0f
MFC r343479: Fix potential buffer overflow and undefined behavior.

The buffer allocated in read_chat() could be 1 element too short, if the
chatstr parameter passed in is 1 or 3 charachters long (e.g. "a" or "a b").
The allocation of the pointer array does not account for the terminating
NULL pointer in that case.

Overlapping source and destination strings are undefined in strcpy().
Instead of moving a string to the left by one character just increment the
char pointer before it is assigned to the results array.
libexec/getty/chat.c