Blame SOURCES/gcc34-CVE-2006-3619.patch

6693b3
2006-07-17  Richard Guenther  <rguenther@suse.de>
6693b3
6693b3
	* jartool.c (extract_jar): Do not allow directory traversal
6693b3
	to parents of the extraction root.
6693b3
6693b3
--- fastjar/jartool.c.jj	2006-07-11 10:53:39.000000000 +0200
6693b3
+++ fastjar/jartool.c	2006-07-18 13:49:39.000000000 +0200
6693b3
@@ -1736,6 +1736,7 @@ int extract_jar(int fd, char **files, in
6693b3
       const ub1 *start = filename;
6693b3
       char *tmp_buff;
6693b3
       struct stat sbuf;
6693b3
+      int depth = 0;
6693b3
 
6693b3
       tmp_buff = malloc(sizeof(char) * strlen((const char *)filename));
6693b3
 
6693b3
@@ -1756,7 +1757,14 @@ int extract_jar(int fd, char **files, in
6693b3
 #ifdef DEBUG    
6693b3
         printf("checking the existance of %s\n", tmp_buff);
6693b3
 #endif
6693b3
-
6693b3
+	if(strcmp(tmp_buff, "..") == 0){
6693b3
+	  --depth;
6693b3
+	  if (depth < 0){
6693b3
+	    fprintf(stderr, "Traversal to parent directories during unpacking!\n");
6693b3
+	    exit(1);
6693b3
+	  }
6693b3
+	} else if (strcmp(tmp_buff, ".") != 0)
6693b3
+	  ++depth;
6693b3
         if(stat(tmp_buff, &sbuf) < 0){
6693b3
           if(errno != ENOENT){
6693b3
             perror("stat");