Blame SOURCES/ncompress-4.2.4.4-filenamelen.patch

a70582
diff --git a/compress42.c b/compress42.c
a70582
index b3b3add..6878046 100644
a70582
--- a/compress42.c
a70582
+++ b/compress42.c
a70582
@@ -141,6 +141,7 @@
a70582
 #include	<sys/types.h>
a70582
 #include	<sys/stat.h>
a70582
 #include	<errno.h>
a70582
+#include	<string.h>
a70582
 
a70582
 #ifdef DIRENT
a70582
 #	include	<dirent.h>
a70582
@@ -214,7 +215,7 @@
a70582
 #	define	OBUFSIZ	BUFSIZ	/* Default output buffer size							*/
a70582
 #endif
a70582
 
a70582
-#define MAXPATHLEN 1024		/* MAXPATHLEN - maximum length of a pathname we allow 	*/
a70582
+#define MAXPATHLEN PATH_MAX 		/* MAXPATHLEN - maximum length of a pathname we allow 	*/
a70582
 #define	SIZE_INNER_LOOP		256	/* Size of the inter (fast) compress loop			*/
a70582
 
a70582
 							/* Defines for third byte of header 					*/
a70582
@@ -701,6 +702,7 @@ main(argc, argv)
a70582
 	{
a70582
     	REG3	char		**filelist;
a70582
 		REG4	char		**fileptr;
a70582
+	int i;
a70582
 
a70582
     	if (fgnd_flag = (signal(SIGINT, SIG_IGN) != SIG_IGN))
a70582
 			signal(SIGINT, (SIG_TYPE)abort_compress);
a70582
@@ -714,13 +716,18 @@ main(argc, argv)
a70582
     	nomagic = 1;	/* Original didn't have a magic number */
a70582
 #endif
a70582
 
a70582
-    	filelist = (char **)malloc(argc*sizeof(char *));
a70582
+	for (i=0; i
a70582
+		if (strlen(argv[i])>(MAXPATHLEN-1)) {
a70582
+			fprintf(stderr,"Filename too long\n");
a70582
+			exit(1);
a70582
+		}
a70582
+	}
a70582
+	filelist = fileptr = (char **)malloc(argc*sizeof(char *));
a70582
     	if (filelist == NULL)
a70582
 		{
a70582
 			fprintf(stderr, "Cannot allocate memory for file list.\n");
a70582
 			exit (1);
a70582
 		}
a70582
-    	fileptr = filelist;
a70582
     	*filelist = NULL;
a70582
 
a70582
     	if((progname = strrchr(argv[0], '/')) != 0)
a70582
@@ -860,7 +867,9 @@ nextarg:	continue;
a70582
 				decompress(0, 1);
a70582
 		}
a70582
 
a70582
+		free(filelist);
a70582
 		exit((exit_code== -1) ? 1:exit_code);
a70582
+		return 0;
a70582
 	}
a70582
 
a70582
 void