~ubuntu-branches/ubuntu/natty/foomatic-filters/natty

« back to all changes in this revision

Viewing changes to debian/patches/01_foomatic-rip-error-out-on-problems-longer-string-buffers.patch

  • Committer: Bazaar Package Importer
  • Author(s): Till Kampeter
  • Date: 2010-06-08 17:47:03 UTC
  • Revision ID: james.westby@ubuntu.com-20100608174703-82avux2q4yk8ar76
Tags: 4.0.4-0ubuntu2
debian/patches/01_foomatic-rip-error-out-on-problems-longer-string-buffers.patch:
Let foomatic-rip actually error out if something goes wrong. It simply
continued or closed silently (exit status 0) on several issues (LP:
570522). Also make string buffers bigger as many of them were too small.
This patch contains the changes which are planned to be introduced in
Foomatic 4.0.5, so this can be considered a test release for 4.0.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//ChangeLog foomatic-filters-4.0.4.new//ChangeLog
 
2
--- foomatic-filters-4.0.4//ChangeLog   2010-02-15 13:57:40.000000000 +0100
 
3
+++ foomatic-filters-4.0.4.new//ChangeLog       2010-06-08 17:19:38.201710562 +0200
 
4
@@ -1,3 +1,32 @@
 
5
+2010-06-08  Till Kamppeter <till.kamppeter@gmail.com>
 
6
+
 
7
+       * USAGE: Documentation correction.
 
8
+
 
9
+2010-06-07  Till Kamppeter <till.kamppeter@gmail.com>
 
10
+
 
11
+       * USAGE: Finally completed the documentation update to reflect that
 
12
+         the Ghostscript library is not needed any more.
 
13
+
 
14
+       * foomaticrip.c, foomaticrip.h, pdf.c: Let foomatic-rip actually
 
15
+         error out if something goes wrong. It simply continued or closed
 
16
+         silently (exit status 0) on the following events: Failure of
 
17
+         print_file() function call, failure of Ghostscript to determine
 
18
+         the number of pages of a PDF input file (causes Ubuntu bug
 
19
+         #570522), failure to start Ghostscript to render a PDF file,
 
20
+         failure to create a temporary file for extracting selected pages
 
21
+         from a PDF file, failure to run Ghostscript to extract pages from
 
22
+         a PDF file, page count result being a negative number.
 
23
+
 
24
+       * foomaticrip.c: Use EXIT_PRINTED constant and not hard-coded "0"
 
25
+         as exit value when terminating successfully.
 
26
+
 
27
+       * foomaticrip.h: Correct definition of EXIT_STARVED constant.
 
28
+
 
29
+2010-03-26  Till Kamppeter <till.kamppeter@gmail.com>
 
30
+
 
31
+       * options.c, options.h: Made some strings longer, to avoid space
 
32
+         problems.
 
33
+
 
34
 2010-02-15  Till Kamppeter <till.kamppeter@gmail.com>
 
35
 
 
36
        * Tagged branch for release 4.0.4.
 
37
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//foomaticrip.c foomatic-filters-4.0.4.new//foomaticrip.c
 
38
--- foomatic-filters-4.0.4//foomaticrip.c       2010-02-15 13:57:40.000000000 +0100
 
39
+++ foomatic-filters-4.0.4.new//foomaticrip.c   2010-06-08 17:19:38.201710562 +0200
 
40
@@ -1602,7 +1602,8 @@
 
41
            PostScript file (all before the first page begins). */
 
42
         optionset_copy_values(optionset("userval"), optionset("header"));
 
43
 
 
44
-        print_file(filename, 1);
 
45
+        if (!print_file(filename, 1))
 
46
+           rip_die(EXIT_PRNERR_NORETRY, "Could not print file %s\n", filename);
 
47
         filename = strtok_r(NULL, " ", &p);
 
48
     }
 
49
 
 
50
@@ -1639,6 +1640,6 @@
 
51
 
 
52
     list_free(arglist);
 
53
 
 
54
-    return 0;
 
55
+    return EXIT_PRINTED;
 
56
 }
 
57
 
 
58
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//foomaticrip.h foomatic-filters-4.0.4.new//foomaticrip.h
 
59
--- foomatic-filters-4.0.4//foomaticrip.h       2010-02-15 13:57:40.000000000 +0100
 
60
+++ foomatic-filters-4.0.4.new//foomaticrip.h   2010-06-08 17:19:38.201710562 +0200
 
61
@@ -56,7 +56,7 @@
 
62
 #define EXIT_JOBERR 3                           /* job is defective */
 
63
 #define EXIT_SIGNAL 4                           /* terminated after catching signal */
 
64
 #define EXIT_ENGAGED 5                          /* printer is otherwise engaged (connection refused) */
 
65
-#define EXIT_STARVED = 6;                       /* starved for system resources */
 
66
+#define EXIT_STARVED 6                          /* starved for system resources */
 
67
 #define EXIT_PRNERR_NORETRY_ACCESS_DENIED 7     /* bad password? bad port permissions? */
 
68
 #define EXIT_PRNERR_NOT_RESPONDING 8            /* just doesn't answer at all (turned off?) */
 
69
 #define EXIT_PRNERR_NORETRY_BAD_SETTINGS 9      /* interface settings are invalid */
 
70
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//options.c foomatic-filters-4.0.4.new//options.c
 
71
--- foomatic-filters-4.0.4//options.c   2010-02-15 13:57:40.000000000 +0100
 
72
+++ foomatic-filters-4.0.4.new//options.c       2010-06-08 17:19:38.211630380 +0200
 
73
@@ -34,10 +34,10 @@
 
74
 
 
75
 /* Values from foomatic keywords in the ppd file */
 
76
 char printer_model [256];
 
77
-char printer_id [128];
 
78
+char printer_id [256];
 
79
 char driver [128];
 
80
-char cmd [1024];
 
81
-char cmd_pdf [1024];
 
82
+char cmd [4096];
 
83
+char cmd_pdf [4096];
 
84
 dstr_t *postpipe = NULL;  /* command into which the output of this
 
85
                              filter should be piped */
 
86
 int ps_accounting = 1;
 
87
@@ -751,7 +751,7 @@
 
88
     {
 
89
         choice_t *choice = option_find_choice(opt, "Custom");
 
90
         char ** paramvalues = paramvalues_from_string(opt, values);
 
91
-        char width[30], height[20];
 
92
+        char width[30], height[30];
 
93
         int pos;
 
94
 
 
95
         assert(choice);
 
96
@@ -1215,7 +1215,7 @@
 
97
     }
 
98
 
 
99
     if (!startswith(code, "%% FoomaticRIPOptionSetting"))
 
100
-        unhtmlify(choice->command, 1024, code);
 
101
+        unhtmlify(choice->command, 65536, code);
 
102
 }
 
103
 
 
104
 /*
 
105
@@ -1529,10 +1529,10 @@
 
106
             unhtmlify(postpipe->data, postpipe->alloc, value->data);
 
107
         }
 
108
         else if (strcmp(key, "FoomaticRIPCommandLine") == 0) {
 
109
-            unhtmlify(cmd, 1024, value->data);
 
110
+            unhtmlify(cmd, 4096, value->data);
 
111
         }
 
112
         else if (strcmp(key, "FoomaticRIPCommandLinePDF") == 0) {
 
113
-            unhtmlify(cmd_pdf, 1024, value->data);
 
114
+            unhtmlify(cmd_pdf, 4096, value->data);
 
115
         }
 
116
         else if (strcmp(key, "FoomaticRIPNoPageAccounting") == 0) {
 
117
             /* Boolean value */
 
118
@@ -1742,7 +1742,7 @@
 
119
      * line */
 
120
     if (startswith(cmd, "gs"))
 
121
     {
 
122
-        strncpy(cmd_pdf, cmd, 1024);
 
123
+        strncpy(cmd_pdf, cmd, 4096);
 
124
         return 1;
 
125
     }
 
126
 
 
127
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//options.h foomatic-filters-4.0.4.new//options.h
 
128
--- foomatic-filters-4.0.4//options.h   2010-02-15 13:57:40.000000000 +0100
 
129
+++ foomatic-filters-4.0.4.new//options.h       2010-06-08 17:19:38.211630380 +0200
 
130
@@ -55,7 +55,7 @@
 
131
 typedef struct choice_s {
 
132
     char value [128];
 
133
     char text [128];
 
134
-    char command[1024];
 
135
+    char command[65536];
 
136
     struct choice_s *next;
 
137
 } choice_t;
 
138
 
 
139
@@ -125,8 +125,8 @@
 
140
 extern char jclend[256];
 
141
 extern char jclprefix[256];
 
142
 
 
143
-extern char cmd[1024];
 
144
-extern char cmd_pdf[1024];
 
145
+extern char cmd[4096];
 
146
+extern char cmd_pdf[4096];
 
147
 
 
148
 extern int ps_accounting;
 
149
 
 
150
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//pdf.c foomatic-filters-4.0.4.new//pdf.c
 
151
--- foomatic-filters-4.0.4//pdf.c       2010-02-15 13:57:40.000000000 +0100
 
152
+++ foomatic-filters-4.0.4.new//pdf.c   2010-06-08 17:19:38.211630380 +0200
 
153
@@ -52,10 +52,8 @@
 
154
             gspath, filename);
 
155
 
 
156
     FILE *pd = popen(gscommand, "r");
 
157
-    if (!pd) {
 
158
-      _log("Failed to execute ghostscript to determine number of input pages!\n");
 
159
-        return 0;
 
160
-    }
 
161
+    if (!pd)
 
162
+      rip_die(EXIT_STARVED, "Failed to execute ghostscript to determine number of input pages!\n");
 
163
 
 
164
     fread(output, 1, 31, pd);
 
165
     pclose(pd);
 
166
@@ -77,7 +75,7 @@
 
167
     _log("Starting renderer with command: %s\n", cmd);
 
168
     kid3 = start_process("kid3", exec_kid3, (void *)cmd, NULL, NULL);
 
169
     if (kid3 < 0)
 
170
-        return 0;
 
171
+        rip_die(EXIT_STARVED, "Could not start renderer\n");
 
172
 
 
173
     return 1;
 
174
 }
 
175
@@ -118,7 +116,7 @@
 
176
     snprintf(filename, PATH_MAX, "%s/foomatic-XXXXXX", temp_dir());
 
177
     mktemp(filename);
 
178
     if (!filename[0])
 
179
-        return 0;
 
180
+        rip_die(EXIT_STARVED, "Unable to create temporary file!\n");
 
181
 
 
182
     snprintf(filename_arg, PATH_MAX, "-sOutputFile=%s", filename);
 
183
     snprintf(first_arg, 50, "-dFirstPage=%d", first);
 
184
@@ -132,10 +130,8 @@
 
185
             gspath, filename_arg, first_arg, last_arg, pdffilename);
 
186
 
 
187
     FILE *pd = popen(gscommand, "r");
 
188
-    if (!pd) {
 
189
-        _log("Could not run ghostscript to extract the pages!\n");
 
190
-        return 0;
 
191
-    }
 
192
+    if (!pd)
 
193
+        rip_die(EXIT_STARVED, "Could not run ghostscript to extract the pages!\n");
 
194
     pclose(pd);
 
195
 
 
196
     return 1;
 
197
@@ -158,7 +154,7 @@
 
198
     else
 
199
     {
 
200
         if (!pdf_extract_pages(tmpfile, filename, firstpage, lastpage))
 
201
-            return 0;
 
202
+            rip_die(EXIT_STARVED, "Could not run ghostscript to extract the pages!\n");
 
203
         dstrcatf(cmd, " < %s", tmpfile);
 
204
     }
 
205
 
 
206
@@ -237,7 +233,7 @@
 
207
     page_count = pdf_count_pages(filename);
 
208
 
 
209
     if (page_count <= 0)
 
210
-        return 0;
 
211
+        rip_die(EXIT_JOBERR, "Unable to determine number of pages, page count: %d\n", page_count);
 
212
     _log("File contains %d pages\n", page_count);
 
213
 
 
214
     optionset_copy_values(optionset("header"), optionset("currentpage"));
 
215
diff -Nur -x '*.orig' -x '*~' foomatic-filters-4.0.4//USAGE foomatic-filters-4.0.4.new//USAGE
 
216
--- foomatic-filters-4.0.4//USAGE       2010-02-15 13:57:40.000000000 +0100
 
217
+++ foomatic-filters-4.0.4.new//USAGE   2010-06-08 17:19:38.201710562 +0200
 
218
@@ -74,9 +74,8 @@
 
219
 Foomatic runs on all systems where one can run the Perl
 
220
 interpreter and Ghostscript.
 
221
 
 
222
-foomatic-filters needs the Ghostscript library for foomatic-rip and
 
223
-the Perl interpreter for beh (Backend Error Handler) and the test
 
224
-suite.
 
225
+foomatic-filters needs the Perl interpreter for beh (Backend Error
 
226
+Handler) and the test suite.
 
227
 
 
228
 To build foomatic-rip you need a C compiler and its standard libraries.
 
229
 
 
230
@@ -138,9 +137,8 @@
 
231
 a normal user.
 
232
 
 
233
 The "configure" script will auto-detect where the programs have to be
 
234
-installed and where the Perl interpreter and the Ghostscript library
 
235
-are located. If "configure" fails because of something not being
 
236
-installed, do
 
237
+installed and where the Perl interpreter is located. If "configure"
 
238
+fails because of something not being installed, do
 
239
 
 
240
    rm -rf config.cache autom*.cache
 
241