## 12_CAN-2004-1186.dpatch by Michael Fedrowitz <michaelf@debian.org>
## DP: Fixed buffer overflows. [CAN-2004-1186]
## DP: Patch provided by the Debian Security Team.
diff -urNad enscript-1.6.4/src/psgen.c /tmp/dpep.YoKxRY/enscript-1.6.4/src/psgen.c
--- enscript-1.6.4/src/psgen.c	2005-01-20 19:59:18.000000000 +0100
+++ /tmp/dpep.YoKxRY/enscript-1.6.4/src/psgen.c	2005-01-20 19:59:30.000000000 +0100
@@ -2034,8 +2034,9 @@
   else
     {
       ftail++;
-      strncpy (buf, fname, ftail - fname);
-      buf[ftail - fname] = '\0';
+      i = ftail - fname >= sizeof (buf)-1 ? sizeof (buf)-1 : ftail - fname;
+      strncpy (buf, fname, i);
+      buf[i] = '\0';
     }
 
   if (nup > 1)
