]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix potential buffer overflow and undefined behavior.
authorse <se@FreeBSD.org>
Sat, 26 Jan 2019 20:43:28 +0000 (20:43 +0000)
committerse <se@FreeBSD.org>
Sat, 26 Jan 2019 20:43:28 +0000 (20:43 +0000)
commit4a8a970d5e5313a749f3378a0a2bd5e995322d26
tree5b16fd0d2361d8921e4ba0fed8249f5babeaeedc
parent2af21b0f61f3de46c91401e8cac339fe08f4a59e
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.

MFC after: 2 weeks
libexec/getty/chat.c