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;
 }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to