pppctl88) Avoid strcpy() copies on overlapping string.

This may lead to unpredicatable behaviour on different platforms or C
library implementations. Use an intermediate variable.

Obtained from:	DragonFlyBSD (git a861a526)
This commit is contained in:
Pedro F. Giffuni 2018-01-29 14:23:44 +00:00
parent 2f2d80f730
commit d282086dec

View File

@ -121,6 +121,7 @@ static int
Receive(int fd, int display)
{
static char Buffer[LINELEN];
char temp[sizeof(Buffer)];
struct timeval t;
int Result;
char *last;
@ -185,7 +186,8 @@ Receive(int fd, int display)
else
flush = last - Buffer + 1;
write(STDOUT_FILENO, Buffer, flush);
strcpy(Buffer, Buffer + flush);
strcpy(temp, Buffer + flush);
strcpy(Buffer, temp);
len -= flush;
}
if ((Result = select(fd + 1, &f, NULL, NULL, &t)) <= 0) {