rebase cont (patch2): max-path-len
Version: 4.2.4.4-1
This commit is contained in:
parent
426d717ee1
commit
e100d74152
@ -1,98 +0,0 @@
|
||||
--- ncompress-4.2.4/compress42.c.filenamelen Wed Nov 21 12:19:38 2001
|
||||
+++ ncompress-4.2.4/compress42.c Wed Nov 21 12:20:03 2001
|
||||
@@ -140,6 +140,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
+#include <string.h>
|
||||
|
||||
#ifdef DIRENT
|
||||
# include <dirent.h>
|
||||
@@ -213,7 +214,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 */
|
||||
@@ -641,13 +642,11 @@
|
||||
} ;
|
||||
#endif
|
||||
|
||||
-void main ARGS((int,char **));
|
||||
void Usage ARGS((void));
|
||||
void comprexx ARGS((char **));
|
||||
void compdir ARGS((char *));
|
||||
void compress ARGS((int,int));
|
||||
void decompress ARGS((int,int));
|
||||
-char *rindex ARGS((char *,int));
|
||||
void read_error ARGS((void));
|
||||
void write_error ARGS((void));
|
||||
void abort_compress ARGS((void));
|
||||
@@ -694,13 +693,15 @@
|
||||
* deterministic, and can be done on the fly. Thus, the decompression
|
||||
* procedure needs no input table, but tracks the way the table was built.
|
||||
*/
|
||||
-void
|
||||
+int
|
||||
main(argc, argv)
|
||||
REG1 int argc;
|
||||
REG2 char *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,7 +715,14 @@
|
||||
nomagic = 1; /* Original didn't have a magic number */
|
||||
#endif
|
||||
|
||||
- filelist = fileptr = (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 *));
|
||||
*filelist = NULL;
|
||||
|
||||
if((progname = rindex(argv[0], '/')) != 0)
|
||||
@@ -853,8 +861,9 @@
|
||||
else
|
||||
decompress(0, 1);
|
||||
}
|
||||
-
|
||||
+
|
||||
exit((exit_code== -1) ? 1:exit_code);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1801,20 +1810,6 @@
|
||||
write_error();
|
||||
}
|
||||
|
||||
-char *
|
||||
-rindex(s, c) /* For those who don't have it in libc.a */
|
||||
- REG1 char *s;
|
||||
- REG2 int c;
|
||||
- {
|
||||
- char *p;
|
||||
-
|
||||
- for (p = NULL; *s; s++)
|
||||
- if (*s == (char)c)
|
||||
- p = s;
|
||||
-
|
||||
- return(p);
|
||||
- }
|
||||
-
|
||||
void
|
||||
read_error()
|
||||
{
|
||||
60
ncompress-4.2.4.4-filenamelen.patch
Normal file
60
ncompress-4.2.4.4-filenamelen.patch
Normal file
@ -0,0 +1,60 @@
|
||||
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
|
||||
@ -16,7 +16,11 @@ Patch0: ncompress-4.2.4.4-make.patch
|
||||
# ~> downstream
|
||||
Patch1: ncompress-4.2.4.4-lfs.patch
|
||||
|
||||
Patch2: ncompress-4.2.4-filenamelen.patch
|
||||
# exit when too long filename is given (do not segfault)
|
||||
# ~> #unknown
|
||||
# ~> downstream
|
||||
Patch2: ncompress-4.2.4.4-filenamelen.patch
|
||||
|
||||
Patch3: ncompress-2GB.patch
|
||||
Patch4: ncompress-4.2.4-zerobyteforce.patch
|
||||
Patch5: ncompress-4.2.4-bssUnderflow.patch
|
||||
|
||||
Loading…
Reference in New Issue
Block a user