Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37524448
en ru br
Репозитории ALT
S:4.2.4.4-alt1
5.1: 4.2.4.2-alt1
4.1: 4.2.4.2-alt1
4.0: 4.2.4-ipl23mdk
3.0: 4.2.4-ipl23mdk
www.altlinux.org/Changes

Группа :: Архивирование/Сжатие
Пакет: ncompress

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: ncompress-4.2.4.4-rh-filenamelen.patch
Скачать


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