File fcrackzip-forkexec-ac.patch of Package fcrackzip

diff -rU3 fcrackzip-1.0/configure.in fcrackzip-forkexec/configure.in
--- fcrackzip-1.0/configure.in	2008-08-04 08:51:05.000000000 +0200
+++ fcrackzip-forkexec/configure.in	2011-11-17 12:02:13.000000000 +0100
@@ -19,6 +19,9 @@
 AC_CHECK_PROGS(PERL,perl5 perl)
 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
 
+AC_PATH_PROG(UNZIP,unzip)
+AC_DEFINE_UNQUOTED([UNZIP], "$UNZIP", [Path to unzip command.])
+
 if test "$GCC" = yes; then
    AC_DEFINE([USE_GCC_ASM], 1, [Define if you can use gcc inline assembly.])
    CFLAGS="$CFLAGS -funroll-all-loops -O3"
diff -rU3 fcrackzip-1.0/main.c fcrackzip-forkexec/main.c
--- fcrackzip-1.0/main.c	2005-09-10 21:58:44.000000000 +0200
+++ fcrackzip-forkexec/main.c	2011-11-17 12:05:45.000000000 +0100
@@ -24,6 +24,8 @@
 #endif
 
 #include <string.h>
+#include <errno.h>
+#include <sys/wait.h>
 
 #ifdef USE_UNIX_REDIRECTION
 #define DEVNULL ">/dev/null 2>&1"
@@ -47,21 +49,34 @@
 int REGPARAM
 check_unzip (const char *pw)
 {
-  char buff[1024];
+  pid_t pid;
   int status;
 
-  sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, pw, file_path[0]);
-  status = system (buff);
+  switch (pid = fork()) {
+    case 0:
+	fclose(stdin);
+	fclose(stdout);
+	fclose(stderr);
+	
+	execl(UNZIP, "unzip", "-qqtP", pw, file_path[0], (char*) NULL);
+	exit(-1);
+    case -1:
+	fprintf(stderr, "fork() failed: %s\n", strerror(errno));
+	exit(-1);
+  }
+  /*fprintf(stderr, "%d forked %d\n", pthread_self(), pid);*/
+  waitpid(pid, &status, 0);
+  /*fprintf(stderr, "%d finished with status %d\n", pid, status);*/
 
 #undef REDIR
 
-  if (status == EXIT_SUCCESS)
+  if (WEXITSTATUS(status) == EXIT_SUCCESS)
     {
       printf("\n\nPASSWORD FOUND!!!!: pw == %s\n", pw);
       exit (EXIT_SUCCESS);
     }
 
-  return !status;
+  return !WEXITSTATUS(status);
 }
 
 /* misc. callbacks.  */
--- fcrackzip-1.0/Makefile.am	2011-11-17 12:13:54.000000000 +0100
+++ fcrackzip-forkexec/Makefile.am	2003-02-09 10:15:00.000000000 +0100
@@ -44,6 +44,6 @@
 	echo -n $(VERSION) >/root/www/nh/fcrackzip-ver.nh
 
 test: all
-	fcrackzip --benchmark
+	./fcrackzip --benchmark
 
 
openSUSE Build Service is sponsored by