Date: Thu, 24 Sep 2009 20:43:08 +0000 (UTC) From: "Stephane E. Potvin" <sepotvin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r197472 - stable/8/gnu/usr.bin/patch Message-ID: <200909242043.n8OKh8Yl007218@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909242043.n8OKh8Yl007218>