[packages/fastjar] Up to 0.98

arekm arekm at pld-linux.org
Sat Nov 28 18:20:53 CET 2026


commit 0969a14f3ef30c9e0fd7017cfdfe76bd364ec70b
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Nov 27 17:22:01 2026 +0100

    Up to 0.98
    
    Fixes CVE-2010-2322, CVE-2010-0831.

 fastjar-jartool.patch | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++
 fastjar.spec          |  14 ++++---
 2 files changed, 120 insertions(+), 6 deletions(-)
---
diff --git a/fastjar.spec b/fastjar.spec
index 06cab4d..67db42b 100644
--- a/fastjar.spec
+++ b/fastjar.spec
@@ -1,16 +1,17 @@
 # TODO:
-# - upgrade to 0.99 https://github.com/FauxFaux/fastjar
 # - Obsoletes: icedtea[67]-jar?
 Summary:	Jar file creation utility
 Summary(pl.UTF-8):	Narzędzie do tworzenia plików jar
 Name:		fastjar
-Version:	0.94
-Release:	2
+Version:	0.98
+Release:	1
 License:	GPL v2+
 Group:		Development/Languages/Java
-Source0:	http://downloads.sourceforge.net/fastjar/%{name}-%{version}.tar.gz
-# Source0-md5:	14d4bdfac236e347d806c6743dba48c6
-URL:		http://fastjar.sourceforge.net/
+Source0:	http://download.savannah.nongnu.org/releases/fastjar/%{name}-%{version}.tar.gz
+# Source0-md5:	d2d264d343d4d0e1575832cc1023c3bf
+Patch0:		%{name}-jartool.patch
+# Patch0 from Debian (jartool.diff): unterminated filename in read_entries, wrong write() error check, extract_jar path handling
+URL:		https://savannah.nongnu.org/projects/fastjar/
 BuildRequires:	autoconf
 BuildRequires:	automake
 BuildRequires:	zlib-devel
@@ -39,6 +40,7 @@ robi to w nieco ponad sekundę.
 
 %prep
 %setup -q
+%patch -P0 -p1
 
 %build
 %{__aclocal}
diff --git a/fastjar-jartool.patch b/fastjar-jartool.patch
new file mode 100644
index 0000000..e5ff44d
--- /dev/null
+++ b/fastjar-jartool.patch
@@ -0,0 +1,112 @@
+--- fastjar-0.98.orig/jartool.c
++++ fastjar-0.98/jartool.c
+@@ -790,6 +790,7 @@ int read_entries (int fd)
+ 		   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 @@ int add_file_to_jar(int jfd, int ffd, co
+       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 @@ int extract_jar(int fd, const char **fil
+       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 @@ int extract_jar(int fd, const char **fil
+         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 @@ int extract_jar(int fd, const char **fil
+ #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 @@ int extract_jar(int fd, const char **fil
+         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 @@ int extract_jar(int fd, const char **fil
+ #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 @@ int extract_jar(int fd, const char **fil
+       exit(EXIT_FAILURE);
+     }
+ 
+-    close(f_fd);
++    if (f_fd != -1)
++      close(f_fd);
+ 
+     if(verbose && dir == FALSE && handle)
+       printf("%10s: %s\n",
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/fastjar.git/commitdiff/0969a14f3ef30c9e0fd7017cfdfe76bd364ec70b



More information about the pld-cvs-commit mailing list