From owner-svn-src-all@FreeBSD.ORG Thu Sep 24 20:43:08 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FE1A1065692; Thu, 24 Sep 2009 20:43:08 +0000 (UTC) (envelope-from sepotvin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DF6D8FC26; Thu, 24 Sep 2009 20:43:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OKh8t4007221; Thu, 24 Sep 2009 20:43:08 GMT (envelope-from sepotvin@svn.freebsd.org) Received: (from sepotvin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OKh8Yl007218; Thu, 24 Sep 2009 20:43:08 GMT (envelope-from sepotvin@svn.freebsd.org) Message-Id: <200909242043.n8OKh8Yl007218@svn.freebsd.org> From: "Stephane E. Potvin" Date: Thu, 24 Sep 2009 20:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197472 - stable/8/gnu/usr.bin/patch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 20:43:08 -0000 Author: sepotvin Date: Thu Sep 24 20:43:08 2009 New Revision: 197472 URL: http://svn.freebsd.org/changeset/base/197472 Log: MFC r197259 The buffer returned by fgetln is not a "C" string and might not be NUL terminated. Make sure that it is before using it. Reviewed by: marck@ Approved by: re (kib) Modified: stable/8/gnu/usr.bin/patch/ (props changed) stable/8/gnu/usr.bin/patch/common.h stable/8/gnu/usr.bin/patch/pch.c Modified: stable/8/gnu/usr.bin/patch/common.h ============================================================================== --- stable/8/gnu/usr.bin/patch/common.h Thu Sep 24 20:34:44 2009 (r197471) +++ stable/8/gnu/usr.bin/patch/common.h Thu Sep 24 20:43:08 2009 (r197472) @@ -34,6 +34,7 @@ #define Strcpy (void)strcpy #define Strcat (void)strcat #define Strlcpy (void)strlcpy +#define Strncpy (void)strncpy #define Strlcat (void)strlcat /* NeXT declares malloc and realloc incompatibly from us in some of Modified: stable/8/gnu/usr.bin/patch/pch.c ============================================================================== --- stable/8/gnu/usr.bin/patch/pch.c Thu Sep 24 20:34:44 2009 (r197471) +++ stable/8/gnu/usr.bin/patch/pch.c Thu Sep 24 20:43:08 2009 (r197472) @@ -1152,7 +1152,8 @@ pgets(bool do_indent) indent++; } } - Strlcpy(buf, line, len + 1 - skipped); + Strncpy(buf, line, len - skipped); + buf[len - skipped] = '\0'; } return len; }