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