]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r343479: Fix potential buffer overflow and undefined behavior.
authorse <se@FreeBSD.org>
Thu, 14 Feb 2019 15:41:05 +0000 (15:41 +0000)
committerse <se@FreeBSD.org>
Thu, 14 Feb 2019 15:41:05 +0000 (15:41 +0000)
commiteed7b9226ff81b9d6be6203c30b92beb2b6f77aa
tree4f0782dacb24d57a9e24bf88bfd57442937dab0d
parent3c086c14ed46c085f3e052007b620758cefd3277
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