HomeFreeBSD

Fix potential buffer overflow and undefined behavior.

Description

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

Details

Provenance
seAuthored on
Parents
rS343478: Catch up with some years of driver development.
Branches
Unknown
Tags
Unknown