Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jan 2018 14:23:45 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328551 - head/usr.sbin/pppctl
Message-ID:  <201801291423.w0TENj8G083137@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Mon Jan 29 14:23:44 2018
New Revision: 328551
URL: https://svnweb.freebsd.org/changeset/base/328551

Log:
  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)

Modified:
  head/usr.sbin/pppctl/pppctl.c

Modified: head/usr.sbin/pppctl/pppctl.c
==============================================================================
--- head/usr.sbin/pppctl/pppctl.c	Mon Jan 29 14:15:44 2018	(r328550)
+++ head/usr.sbin/pppctl/pppctl.c	Mon Jan 29 14:23:44 2018	(r328551)
@@ -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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801291423.w0TENj8G083137>