svn commit: r197472 - stable/8/gnu/usr.bin/patch

Stephane E. Potvin sepotvin at FreeBSD.org
Thu Sep 24 20:43:08 UTC 2009


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;
 }


More information about the svn-src-stable-8 mailing list