rpms/cbrpager/devel cbrpager-0.9.16-filen-shell-escaping.patch, NONE, 1.1 cbrpager-0.9.16-remove-critical-warning.patch, NONE, 1.1 .cvsignore, 1.2, 1.3 cbrpager.spec, 1.1, 1.2 sources, 1.2, 1.3 cbrpager-0.9.15-remove-critical-warning.patch, 1.1, NONE

Mamoru Tasaka (mtasaka) fedora-extras-commits at redhat.com
Fri May 23 08:35:27 UTC 2008


Author: mtasaka

Update of /cvs/extras/rpms/cbrpager/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32672/devel

Modified Files:
	.cvsignore cbrpager.spec sources 
Added Files:
	cbrpager-0.9.16-filen-shell-escaping.patch 
	cbrpager-0.9.16-remove-critical-warning.patch 
Removed Files:
	cbrpager-0.9.15-remove-critical-warning.patch 
Log Message:
* Fri May 23 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 0.9.16-1
- 0.9.16
- Properly handle file name (shell escaping issue)


cbrpager-0.9.16-filen-shell-escaping.patch:

--- NEW FILE cbrpager-0.9.16-filen-shell-escaping.patch ---
--- cbrpager-0.9.16/src/global.c.filen	2008-05-23 14:53:51.000000000 +0900
+++ cbrpager-0.9.16/src/global.c	2008-05-23 17:11:33.000000000 +0900
@@ -36,6 +36,12 @@
 #include "conf.h"
 #include "main.h"
 
+#include <unistd.h>
+#include <sys/types.h> /* creat */
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/wait.h> /* wait */
+
 GList           *pagelist = NULL;
 int		 page_nr = 0,
 		 timer_id = 0,
@@ -144,19 +150,23 @@
   char *bff, *p = NULL, **names;
   gboolean first = TRUE;
   int s, t, bffbeg = 0;
+  int pfd[2]; /* pipe */
+  int pid_i, pid_j; /* two children*/
+  int wait_i, wait_j; /* waiting pid */
+  char cmd[3][20];
 
   if (debug) printf("%s\n", pref.lastbook);
 
   switch (pref.booktype = file_type_of(pref.lastbook)) {
     case ZIP_FILE:
-      bff = g_strdup_printf("unzip -l \"%s\" | grep \"%s\" > %s",
-		pref.lastbook, all_extensions, tmpf);
-      if (debug) printf("ZIP command: %s\n", bff);
+      sprintf(cmd[0], "%s", "unzip");
+      sprintf(cmd[1], "%s", "-l");
+      sprintf(cmd[2], "ZIP command:");
       break;
     case RAR_FILE:
-      bff = g_strdup_printf("unrar v \"%s\" | grep \"%s\" > %s",
-		pref.lastbook, all_extensions, tmpf);
-      if (debug) printf("RAR command: %s\n", bff);
+      sprintf(cmd[0], "%s", "unrar");
+      sprintf(cmd[1], "%s", "v");
+      sprintf(cmd[2], "RAR command:");
       break;
     default:			// Patch from Ilja Pyykkonen 2005/09/04
       p = g_strdup_printf(_("Cannot open file '%s': unknown file type"), 
@@ -165,7 +175,77 @@
       g_free(p);
       return;
   }
-  system(bff);
+
+  if(pipe(pfd) == -1) {
+    fprintf(stderr, "Creating pipe failed\n");
+    return;
+  }
+
+  pid_i = fork(); 
+  if (pid_i == -1) {
+    fprintf(stderr, "Forking failed\n");
+    return;
+  }
+  else if (pid_i == 0) { /* child 1: do unzip or unrar */
+    close(pfd[0]);
+    close(1); /* close stdout*/
+    if (dup(pfd[1]) != 1 ) {
+      fprintf(stderr, "Dup failure\n");
+      return;
+    }
+    close(pfd[1]);
+    if (debug) fprintf(stderr, "%s %s %s %s\n", 
+		cmd[2], cmd[0], cmd[1], pref.lastbook);
+    execlp(cmd[0], cmd[0], cmd[1], pref.lastbook, NULL);
+    return; /* should not reach here */
+  }
+  else {
+    pid_j = fork() ; 
+    if (pid_j == -1) {
+      fprintf(stderr, "Forking failed\n");
+      return;
+    }
+    else if (pid_j == 0) { /* child 2; do grep */
+      int new_fd;
+
+      close(pfd[1]);
+      close(0); /* close stdin */
+      if (dup(pfd[0]) != 0) {
+        fprintf(stderr, "Dup failure\n");
+        return;
+      }
+      close(pfd[0]);
+      /* create tmpf */
+      if ((new_fd = creat(tmpf, 00600)) == -1) {
+        p = g_strdup_printf(_("Cannot open file '%s'"), tmpf);
+        ok_dialog(_("File error"), p);
+        g_free(p);
+        return;
+      }
+      close(1); /* close stdout */
+      if (dup(new_fd) != 1) {
+        fprintf(stderr, "Dup failure\n");
+        return;
+      }
+      close(new_fd);
+      execlp("grep", "grep", all_extensions, NULL);
+      return; /* should not reach here */
+    }
+    else { /* parent */
+      close(pfd[0]);
+      close(pfd[1]);
+      /* wait children */
+      wait_i = wait(0);
+      wait_j = wait(0);
+     if (!((wait_i == pid_i && wait_j == pid_j) || 
+	(wait_i == pid_j && wait_j == pid_i))) {
+        fprintf(stderr, "Forked children status strange\n");
+        return;
+     }
+
+    }
+  }
+  bff = NULL;
 
   if (!g_file_test(tmpf, G_FILE_TEST_EXISTS)) {
     printf(_("Cannot open temporary file %s\n"), tmpf);
@@ -236,7 +316,10 @@
 {
   char *p, *bff = NULL, *esc;
   int len, i, idx = 0;
-  
+
+  int pid;
+  int fd;
+
   p = (char *)g_list_nth_data(pagelist, nr);
   len = strlen(p);
   esc = g_malloc(2*len + 1);
@@ -254,21 +337,42 @@
 
   printf(_("Requesting page %d/%d (%s)\n"), nr+1, g_list_length(pagelist), esc);
 
-  switch (pref.booktype) {
-    case RAR_FILE:
-      bff = g_strdup_printf("unrar p -ierr -clr -- \"%s\" \"%s\" > %s",
-		pref.lastbook,
-		p,
-		tmpf);
-      break;
-    case ZIP_FILE:
-      bff = g_strdup_printf("unzip -p -C \"%s\" \"%s\" > %s",
-                pref.lastbook,
-                p,
-                tmpf);
-      break;
+  pid = fork();
+  switch (pid) {
+    case -1:
+      fprintf(stderr, "Forking failed\n");
+      return;
+    case 0: /* child */
+      if ((fd = creat(tmpf, 00600)) == -1) {
+        p = g_strdup_printf(_("Cannot open file '%s'"), tmpf);
+        ok_dialog(_("File error"), p);
+        g_free(p);
+        return;
+      }
+      close(1); /* close stdout */
+      if (dup(fd) != 1) {
+        fprintf(stderr, "Dup failure\n");
+        return;
+      }
+      close(fd);
+      switch(pref.booktype) {
+        case RAR_FILE:
+          execlp("unrar",
+			"unrar", "p", "-ierr", "-clr", "--",
+			pref.lastbook, p, NULL);
+          return; /* should not reach here */
+        case ZIP_FILE:
+          execlp("unzip",
+			"unzip", "-p", "-C",
+			pref.lastbook, p, NULL);
+          return; /* should not return here */
+      }
+      return; /* should not reach here */
+    default: /* parent */
+      waitpid(pid, 0, 0);
   }
-  system(bff);
+
+  bff = NULL;
   g_free(bff);
   g_free(esc);
   

cbrpager-0.9.16-remove-critical-warning.patch:

--- NEW FILE cbrpager-0.9.16-remove-critical-warning.patch ---
--- cbrpager-0.9.16/src/global.c.debug	2008-05-22 23:10:32.000000000 +0900
+++ cbrpager-0.9.16/src/global.c	2008-05-23 14:53:51.000000000 +0900
@@ -28,6 +28,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <ctype.h>
+
 #include "support.h"
 #include "interface.h"
 #include "global.h"
@@ -139,9 +141,9 @@
 start_show(void)
 {
   GtkWidget *w;
-  char *bff, *p, **names;
+  char *bff, *p = NULL, **names;
   gboolean first = TRUE;
-  int s, t, bffbeg;
+  int s, t, bffbeg = 0;
 
   if (debug) printf("%s\n", pref.lastbook);
 
@@ -166,7 +168,7 @@
   system(bff);
 
   if (!g_file_test(tmpf, G_FILE_TEST_EXISTS)) {
-    printf(_("Cannot open temporary file %s\n"), tmpfile);
+    printf(_("Cannot open temporary file %s\n"), tmpf);
     g_free(bff);
     return;
   }
@@ -215,7 +217,9 @@
   GtkWidget *wdg;
   GtkAdjustment *adj;
 
+#if 0
   if (debug) printf("[scroll] to %.2f\n");
+#endif
   wdg = lookup_widget(MainWindow, "main_scroller");
   adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(wdg));
   if (debug)
@@ -230,7 +234,7 @@
 void
 request_page(int nr, GdkPixbuf **pxm, double *w, double *h)
 {
-  char *p, *bff, *esc;
+  char *p, *bff = NULL, *esc;
   int len, i, idx = 0;
   
   p = (char *)g_list_nth_data(pagelist, nr);
--- cbrpager-0.9.16/src/global.h.debug	2007-06-13 13:44:11.000000000 +0900
+++ cbrpager-0.9.16/src/global.h	2008-05-23 03:14:28.000000000 +0900
@@ -43,3 +43,5 @@
 void		set_zoom_fit(void);
 void		fit_page(int w, int h);
 void		fit_width(int w);
+
+void		set_zoom_width(void);


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/cbrpager/devel/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	22 Mar 2008 01:18:26 -0000	1.2
+++ .cvsignore	23 May 2008 08:34:43 -0000	1.3
@@ -1 +1 @@
-cbrpager-0.9.15.tar.gz
+cbrpager-0.9.16.tar.gz


Index: cbrpager.spec
===================================================================
RCS file: /cvs/extras/rpms/cbrpager/devel/cbrpager.spec,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cbrpager.spec	22 Mar 2008 01:18:26 -0000	1.1
+++ cbrpager.spec	23 May 2008 08:34:43 -0000	1.2
@@ -1,5 +1,5 @@
 Name:		cbrpager
-Version:	0.9.15
+Version:	0.9.16
 Release:	1%{?dist}
 Summary:	Simple comic book pager for Linux
 
@@ -7,7 +7,8 @@
 License:	GPLv2+
 URL:		http://www.jcoppens.com/soft/cbrpager/index.en.php
 Source0:	http://downloads.sourceforge.net/cbrpager/%{name}-%{version}.tar.gz
-Patch0:		cbrpager-0.9.15-remove-critical-warning.patch
+Patch0:		cbrpager-0.9.16-remove-critical-warning.patch
+Patch1:		cbrpager-0.9.16-filen-shell-escaping.patch
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:	libgnomeui-devel
@@ -23,7 +24,8 @@
 
 %prep
 %setup -q
-%patch0 -p1 -b .warn
+%patch0 -p1 -b .debug
+%patch1 -p1 -b .filen
 
 for f in \
 	ChangeLog \
@@ -80,6 +82,10 @@
 
 
 %changelog
+* Fri May 23 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 0.9.16-1
+- 0.9.16
+- Properly handle file name (shell escaping issue)
+
 * Fri Mar 21 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 0.9.15-1
 - Initial packaging
 


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/cbrpager/devel/sources,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sources	22 Mar 2008 01:18:26 -0000	1.2
+++ sources	23 May 2008 08:34:43 -0000	1.3
@@ -1 +1 @@
-ae0ded67962f06e0511dd7d4c4777e13  cbrpager-0.9.15.tar.gz
+add0a550c54f48650f11a4eadaefc540  cbrpager-0.9.16.tar.gz


--- cbrpager-0.9.15-remove-critical-warning.patch DELETED ---




More information about the fedora-extras-commits mailing list