Date: Wed, 16 Sep 2009 19:53:30 +0000 (UTC) From: "Stephane E. Potvin" <sepotvin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r197259 - head/gnu/usr.bin/patch Message-ID: <200909161953.n8GJrU5H034400@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sepotvin Date: Wed Sep 16 19:53:29 2009 New Revision: 197259 URL: http://svn.freebsd.org/changeset/base/197259 Log: The buffer returned by fgenln is not a "C" string and might not be NUL terminated. Make sure that it is before using it. Reviewed by: marck@ MFC after: 3 days Modified: head/gnu/usr.bin/patch/common.h head/gnu/usr.bin/patch/pch.c Modified: head/gnu/usr.bin/patch/common.h ============================================================================== --- head/gnu/usr.bin/patch/common.h Wed Sep 16 14:47:50 2009 (r197258) +++ head/gnu/usr.bin/patch/common.h Wed Sep 16 19:53:29 2009 (r197259) @@ -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: head/gnu/usr.bin/patch/pch.c ============================================================================== --- head/gnu/usr.bin/patch/pch.c Wed Sep 16 14:47:50 2009 (r197258) +++ head/gnu/usr.bin/patch/pch.c Wed Sep 16 19:53:29 2009 (r197259) @@ -1176,7 +1176,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?200909161953.n8GJrU5H034400>