This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[FASTJAR PATCH] Fix jar c something.class > something.jar


Hi!

jar c somefile.class > somefile.jar
would segfault (unlike
jar cf somefile.jar somefile.class
), because jarfile is NULL.
The other change is something I noticed while trying to build
fastjar standalone to debug this - the endian detection code
uses HAVE_LIMITS_H define, yet fastjar's configury never checks for that
header and thus it fails.

Ok to commit?

2002-10-10  Jakub Jelinek  <jakub@redhat.com>

	* jartool.c (add_to_jar): Only compare file to jarfile if jarfile is
	non-NULL.

	* configure.in (AC_CHECK_HEADERS): Add limits.h.
	* configure, config.h.in: Rebuilt.
	
--- fastjar/jartool.c.jj	2002-10-22 23:51:37.000000000 +0200
+++ fastjar/jartool.c	2002-11-10 22:03:10.000000000 +0100
@@ -843,7 +843,7 @@ int add_to_jar(int fd, const char *new_d
     }
   }
 
-  if(!strcmp(file, jarfile)){
+  if(jarfile && !strcmp(file, jarfile)){
     if(verbose)
       printf("skipping: %s\n", file);
     return 0;  /* we don't want to add ourselves.. */
@@ -924,7 +924,8 @@ int add_to_jar(int fd, const char *new_d
     while(!use_explicit_list_only && (de = readdir(dir)) != NULL){
       if(de->d_name[0] == '.')
         continue;
-      if(!strcmp(de->d_name, jarfile)){ /* we don't want to add ourselves.  Believe me */
+      if(jarfile && !strcmp(de->d_name, jarfile)){
+	/* we don't want to add ourselves.  Believe me */
         if(verbose)
           printf("skipping: %s\n", de->d_name);
         continue;
--- fastjar/configure.in.jj	2002-10-22 23:51:37.000000000 +0200
+++ fastjar/configure.in	2002-11-10 21:54:40.000000000 +0100
@@ -24,7 +24,7 @@ dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_STRUCT_TM
-AC_CHECK_HEADERS(fcntl.h unistd.h sys/param.h stdlib.h)
+AC_CHECK_HEADERS(fcntl.h unistd.h sys/param.h stdlib.h limits.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_OFF_T
--- fastjar/configure.jj	2002-10-22 23:51:37.000000000 +0200
+++ fastjar/configure	2002-11-10 21:54:56.000000000 +0100
@@ -1691,7 +1691,7 @@ EOF
 
 fi
 
-for ac_hdr in fcntl.h unistd.h sys/param.h stdlib.h
+for ac_hdr in fcntl.h unistd.h sys/param.h stdlib.h limits.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
--- fastjar/config.h.in.jj	2002-10-22 23:51:37.000000000 +0200
+++ fastjar/config.h.in	2002-11-10 21:55:22.000000000 +0100
@@ -21,6 +21,9 @@
 /* Define if you have the <stdlib.h> header file.  */
 #undef HAVE_STDLIB_H
 
+/* Define if you have the <limits.h> header file.  */
+#undef HAVE_LIMITS_H
+
 /* Define if you have the <sys/dir.h> header file.  */
 #undef HAVE_SYS_DIR_H
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]