From 72686d316d4e9bdfa949ea7e4c9311ae9202144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 12 Jan 2022 10:24:03 +0000 Subject: [PATCH] add forgotten files. --- app-arch/fastjar/Manifest | 1 + app-arch/fastjar/files/0.98-traversal.patch | 112 ++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 app-arch/fastjar/files/0.98-traversal.patch diff --git a/app-arch/fastjar/Manifest b/app-arch/fastjar/Manifest index 81d4572..7885e15 100644 --- a/app-arch/fastjar/Manifest +++ b/app-arch/fastjar/Manifest @@ -1,2 +1,3 @@ +AUX 0.98-traversal.patch 3010 BLAKE2B 76450d561450aa9c7d5386f53328c0037d6ce9df2d6aac79deb1e47cee7651723cf2863a0d27cb6431a58525a9d0d3c554820b4f22a3099d1fe43b2ea7bec0d1 SHA512 7bfcfebd681f9556e8231786da3326d12ee7ab071e2cadf9a4c17ba4e4e750aeb7e3d7cd78634c36e05179df4a369aae2e04a22533d1954668ada95f1d53d311 DIST fastjar-0.98.tar.gz 717984 BLAKE2B 1715f1917076799fc58c6c6cea8fb53fc3261a694fa2392c0dc6e30101a7d42de0c5c55cd593627b4d2d0ffa45e3d44ef220c9579caec669721c6b1b9996e43c SHA512 c0f9fca7b58d6acd00b90a5184dbde9ba3ffc5bf4d69512743e450649a272baf1f6af98b15d79d2b53990eaf84ef402c986035e6b615a19e35ed424348143903 EBUILD fastjar-0.98-r3.ebuild 506 BLAKE2B dc56b00997ac79eb65edefc34910e1b92467a70130d4a9a9ffa14007d17b1af509443ee28084505f155e7b54f003e5e4576c287c7ad48b5b73adef146c9343c8 SHA512 bf064fe246a4b5c4061c52e60fc2f41aa169e247304500aa7481a28b527666d0ed21db17bc209ddf061d410c43c862dc22163bc77c26626b99b710a667b1f345 diff --git a/app-arch/fastjar/files/0.98-traversal.patch b/app-arch/fastjar/files/0.98-traversal.patch new file mode 100644 index 0000000..511f4c6 --- /dev/null +++ b/app-arch/fastjar/files/0.98-traversal.patch @@ -0,0 +1,112 @@ +--- fastjar-0.98.orig/jartool.c ++++ fastjar-0.98/jartool.c +@@ -790,6 +790,7 @@ + progname, jarfile); + return 1; + } ++ ze->filename[len] = '\0'; + len = UNPACK_UB4(header, CEN_EFLEN); + len += UNPACK_UB4(header, CEN_COMLEN); + if (lseek (fd, len, SEEK_CUR) == -1) +@@ -1257,7 +1258,7 @@ + exit_on_error("write"); + + /* write the file name to the zip file */ +- if (1 == write(jfd, fname, file_name_length)) ++ if (-1 == write(jfd, fname, file_name_length)) + exit_on_error("write"); + + if(verbose){ +@@ -1730,7 +1731,17 @@ + struct stat sbuf; + int depth = 0; + +- tmp_buff = malloc(sizeof(char) * strlen((const char *)filename)); ++ if(*filename == '/'){ ++ fprintf(stderr, "Absolute path names are not allowed.\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ tmp_buff = malloc(strlen((const char *)filename)); ++ ++ if(tmp_buff == NULL) { ++ fprintf(stderr, "Out of memory.\n"); ++ exit(EXIT_FAILURE); ++ } + + for(;;){ + const ub1 *idx = (const unsigned char *)strchr((const char *)start, '/'); +@@ -1738,25 +1749,28 @@ + if(idx == NULL) + break; + else if(idx == start){ ++ tmp_buff[idx - filename] = '/'; + start++; + continue; + } +- start = idx + 1; + +- strncpy(tmp_buff, (const char *)filename, (idx - filename)); +- tmp_buff[(idx - filename)] = '\0'; ++ memcpy(tmp_buff + (start - filename), (const char *)start, (idx - start)); ++ tmp_buff[idx - filename] = '\0'; + + #ifdef DEBUG + printf("checking the existance of %s\n", tmp_buff); + #endif +- if(strcmp(tmp_buff, "..") == 0){ ++ if(idx - start == 2 && memcmp(start, "..", 2) == 0){ + --depth; + if (depth < 0){ + fprintf(stderr, "Traversal to parent directories during unpacking!\n"); + exit(EXIT_FAILURE); + } +- } else if (strcmp(tmp_buff, ".") != 0) ++ } else if (idx - start != 1 || *start != '.') + ++depth; ++ ++ start = idx + 1; ++ + if(stat(tmp_buff, &sbuf) < 0){ + if(errno != ENOENT) + exit_on_error("stat"); +@@ -1765,6 +1779,7 @@ + #ifdef DEBUG + printf("Directory exists\n"); + #endif ++ tmp_buff[idx - filename] = '/'; + continue; + }else { + fprintf(stderr, "Hmmm.. %s exists but isn't a directory!\n", +@@ -1781,10 +1796,11 @@ + if(verbose && handle) + printf("%10s: %s/\n", "created", tmp_buff); + ++ tmp_buff[idx - filename] = '/'; + } + + /* only a directory */ +- if(strlen((const char *)start) == 0) ++ if(*start == '\0') + dir = TRUE; + + #ifdef DEBUG +@@ -1792,7 +1808,7 @@ + #endif + + /* If the entry was just a directory, don't write to file, etc */ +- if(strlen((const char *)start) == 0) ++ if(*start == '\0') + f_fd = -1; + + free(tmp_buff); +@@ -1876,7 +1892,8 @@ + exit(EXIT_FAILURE); + } + +- close(f_fd); ++ if (f_fd != -1) ++ close(f_fd); + + if(verbose && dir == FALSE && handle) + printf("%10s: %s\n",