Blame SOURCES/recode-longfilename.patch

cd41d9
diff -u -r recode-3.6.orig/src/common.h recode-3.6/src/common.h
cd41d9
--- recode-3.6.orig/src/common.h	2000-06-28 20:40:15.000000000 +0200
cd41d9
+++ recode-3.6/src/common.h	2017-10-03 13:52:09.904644383 +0200
cd41d9
@@ -56,13 +56,14 @@
cd41d9
 # define RETSIGTYPE void
cd41d9
 #endif
cd41d9
 
cd41d9
-#if DIFF_HASH
cd41d9
-# ifdef HAVE_LIMITS_H
cd41d9
-#  include <limits.h>
cd41d9
-# endif
cd41d9
-# ifndef CHAR_BIT
cd41d9
-#  define CHAR_BIT 8
cd41d9
-# endif
cd41d9
+#ifdef HAVE_LIMITS_H
cd41d9
+# include <limits.h>
cd41d9
+#endif
cd41d9
+#ifndef CHAR_BIT
cd41d9
+# define CHAR_BIT 8
cd41d9
+#endif
cd41d9
+#ifndef PATH_MAX
cd41d9
+# define PATH_MAX 4096
cd41d9
 #endif
cd41d9
 
cd41d9
 /* Some systems do not define EXIT_*, even with STDC_HEADERS.  */
cd41d9
diff -u -r recode-3.6.orig/src/main.c recode-3.6/src/main.c
cd41d9
--- recode-3.6.orig/src/main.c	2000-12-06 20:44:59.000000000 +0100
cd41d9
+++ recode-3.6/src/main.c	2017-10-03 14:32:51.274017940 +0200
cd41d9
@@ -847,7 +847,7 @@
cd41d9
 	  for (; optind < argc; optind++)
cd41d9
 	    {
cd41d9
 	      const char *input_name;
cd41d9
-	      char output_name[200]; /* FIXME: dangerous limit */
cd41d9
+	      char output_name[PATH_MAX];
cd41d9
 	      FILE *file;
cd41d9
 	      struct stat file_stat;
cd41d9
 	      struct utimbuf file_utime;
cd41d9
@@ -871,7 +871,12 @@
cd41d9
 
cd41d9
 		/* FIXME: Scott Schwartz <schwartz@bio.cse.psu.edu> writes:
cd41d9
 		   "There's no reason to think that that name is unique."  */
cd41d9
-
cd41d9
+        // To avoid overflows, the size of the array pointed by destination (output_name)
cd41d9
+        // shall be long enough to contain the same C string as source
cd41d9
+        // (including the terminating null character).
cd41d9
+        if (strlen(input_name) >= PATH_MAX) {
cd41d9
+            error (EXIT_FAILURE, 0, "input_name reach the PATH_MAX limit");
cd41d9
+        }
cd41d9
 		strcpy (output_name, input_name);
cd41d9
 #if DOSWIN_OR_OS2
cd41d9
 		for (cursor = output_name + strlen (output_name);