--- branches/gcc-4_0-branch/fastjar/jartool.c 2006/08/05 09:27:11 115945 +++ branches/gcc-4_0-branch/fastjar/jartool.c 2006/08/05 09:43:02 115946 @@ -1724,6 +1724,7 @@ const ub1 *start = filename; char *tmp_buff; struct stat sbuf; + int depth = 0; tmp_buff = malloc(sizeof(char) * strlen((const char *)filename)); @@ -1744,7 +1745,14 @@ #ifdef DEBUG printf("checking the existance of %s\n", tmp_buff); #endif - + if(strcmp(tmp_buff, "..") == 0){ + --depth; + if (depth < 0){ + fprintf(stderr, "Traversal to parent directories during unpacking!\n"); + exit(1); + } + } else if (strcmp(tmp_buff, ".") != 0) + ++depth; if(stat(tmp_buff, &sbuf) < 0){ if(errno != ENOENT){ perror("stat");