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

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