OCaml 4.14.0 rebuild
[arch-packages.git] / netpbm / trunk / netpbm-security-scripts.patch
blob0dfe84f438d18cda089ae38b60626d795dbbf223
1 diff --git a/converter/other/anytopnm b/converter/other/anytopnm
2 index acf8813..335312a 100755
3 --- a/converter/other/anytopnm
4 +++ b/converter/other/anytopnm
5 @@ -511,10 +511,7 @@ else
6 inputFile="-"
7 fi
9 -tempdir="${TMPDIR-/tmp}/anytopnm.$$"
10 -mkdir -m 0700 $tempdir || \
11 - { echo "Could not create temporary file. Exiting."; exit 1;}
12 -trap 'rm -rf $tempdir' 0
13 +tempdir=$(mktemp -d -t anytopnm.XXXXXXXXXX) || exit 1
15 # Take out all spaces
16 # Find the filename extension for last-ditch efforts later
17 @@ -537,12 +534,17 @@ typeDescription=`file "$file" | cut -d: -f2- | cut -c2-`
18 determineType "$file" "$mimeType" "$typeDescription" "$fileExtension"
20 if [ "$filetype" = "unknown" ]; then
21 - echo "$progname: unknown file type. " \
22 - "'file' says mime type is '$mimeType', " 1>&2
23 - echo "type description is '$typeDescription'" 1>&2
24 + if [ -d "$tempdir" ] ; then
25 + rm -rf "$tempdir"
26 + fi
28 exit 1
31 convertIt $file $filetype
33 +if [ -d "$tempdir" ] ; then
34 + rm -rf "$tempdir"
35 +fi
37 exit 0
38 diff --git a/editor/pamstretch-gen b/editor/pamstretch-gen
39 index ba0e818..250fca0 100755
40 --- a/editor/pamstretch-gen
41 +++ b/editor/pamstretch-gen
42 @@ -31,9 +31,7 @@ if [ "$1" = "" ]; then
43 exit 1
46 -tempdir="${TMPDIR-/tmp}/pamstretch-gen.$$"
47 -mkdir -m 0700 $tempdir || \
48 - { echo "Could not create temporary file. Exiting."; exit 1;}
49 +tempfile=$(mktemp /tmp/pnmig.XXXXXXXXXX) || exit 1
50 trap 'rm -rf $tempdir' 0 1 3 15
52 tempfile=$tempdir/pnmig
53 diff --git a/editor/pnmmargin b/editor/pnmmargin
54 index 0f57d1d..e0d3625 100755
55 --- a/editor/pnmmargin
56 +++ b/editor/pnmmargin
57 @@ -11,11 +11,7 @@
58 # documentation. This software is provided "as is" without express or
59 # implied warranty.
61 -tempdir="${TMPDIR-/tmp}/pnmmargin.$$"
62 -mkdir -m 0700 $tempdir || \
63 - { echo "Could not create temporary file. Exiting." 1>&2; exit 1;}
64 -trap 'rm -rf $tempdir' 0 1 3 15
66 +tempdir=$(mktemp -d -t ppmmargin.XXXXXXX) || exit 1
67 tmp1=$tempdir/pnmm1
68 tmp2=$tempdir/pnmm2
69 tmp3=$tempdir/pnmm3
70 @@ -90,6 +86,7 @@ else
71 -white | -black )
72 pnmpad $plainopt $color \
73 -left=$size -right=$size -top=$size -bottom=$size $tmp1
74 + rm -rf "$tempdir"
75 exit
77 * )
78 @@ -103,4 +100,4 @@ else
79 pnmcat -tb $plainopt $tmp3 $tmp4 $tmp3
83 +rm -rf "$tempdir"
84 diff --git a/editor/ppmfade b/editor/ppmfade
85 index 027fc79..8eb094f 100755
86 --- a/editor/ppmfade
87 +++ b/editor/ppmfade
88 @@ -40,6 +40,7 @@ exec perl -w -x -S -- "$0" "$@"
90 ##############################################################################
91 use strict;
92 +use File::Temp "tempdir";
94 my $SPREAD = 1;
95 my $SHIFT = 2;
96 @@ -137,20 +138,26 @@ if ($first_file ne "undefined") {
98 print("Frames are " . $width . "W x " . $height . "H\n");
101 +# We create a tmp-directory right here
103 +my $tmpdir = tempdir("ppmfade.XXXXXX", CLEANUP => 1);
106 if ($first_file eq "undefined") {
107 print "Fading from black to ";
108 - system("ppmmake \\#000 $width $height >junk1$$.ppm");
109 + system("ppmmake \\#000 $width $height >$tmpdir/junk1$$.ppm");
110 } else {
111 print "Fading from $first_file to ";
112 - system("cp", $first_file, "junk1$$.ppm");
113 + system("cp", $first_file, "$tmpdir/junk1$$.ppm");
116 if ($last_file eq "undefined") {
117 print "black.\n";
118 - system("ppmmake \\#000 $width $height >junk2$$.ppm");
119 + system("ppmmake \\#000 $width $height >$tmpdir/junk2$$.ppm");
120 } else {
121 print "$last_file\n";
122 - system("cp", $last_file, "junk2$$.ppm");
123 + system("cp", $last_file, "$tmpdir/junk2$$.ppm");
127 @@ -158,14 +165,14 @@ if ($last_file eq "undefined") {
130 # Here's what our temporary files are:
131 -# junk1$$.ppm: The original (fade-from) image
132 -# junk2$$.ppm: The target (fade-from) image
133 -# junk3$$.ppm: The frame of the fade for the current iteration of the
134 -# the for loop.
135 -# junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
136 -# image to another, this is the first frame of that
137 -# sequence.
138 -# junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
139 +# $tmpdir/junk1$$.ppm: The original (fade-from) image
140 +# $tmpdir/junk2$$.ppm: The target (fade-from) image
141 +# $tmpdir/junk3$$.ppm: The frame of the fade for the current iteration of the
142 +# the for loop.
143 +# $tmpdir/junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
144 +# image to another, this is the first frame of that
145 +# sequence.
146 +# $tmpdir/junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
148 my $i; # Frame number
149 for ($i = 1; $i <= $nframes; $i++) {
150 @@ -173,147 +180,147 @@ for ($i = 1; $i <= $nframes; $i++) {
151 if ($mode eq $SPREAD) {
152 if ($i <= 10) {
153 my $n = $spline20[$i] * 100;
154 - system("ppmspread $n junk1$$.ppm >junk3$$.ppm");
155 + system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
156 } elsif ($i <= 20) {
157 my $n;
158 $n = $spline20[$i] * 100;
159 - system("ppmspread $n junk1$$.ppm >junk1a$$.ppm");
160 + system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
161 $n = (1-$spline20[$i-10]) * 100;
162 - system("ppmspread $n junk2$$.ppm >junk2a$$.ppm");
163 + system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
164 $n = $spline10[$i-10];
165 - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
166 + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
167 } else {
168 my $n = (1-$spline20[$i-10])*100;
169 - system("ppmspread $n junk2$$.ppm >junk3$$.ppm");
170 + system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
172 } elsif ($mode eq $SHIFT) {
173 if ($i <= 10) {
174 my $n = $spline20[$i] * 100;
175 - system("ppmshift $n junk1$$.ppm >junk3$$.ppm");
176 + system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
177 } elsif ($i <= 20) {
178 my $n;
179 $n = $spline20[$i] * 100;
180 - system("ppmshift $n junk1$$.ppm >junk1a$$.ppm");
181 + system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
182 $n = (1-$spline20[$i-10])*100;
183 - system("ppmshift $n junk2$$.ppm >junk2a$$.ppm");
184 + system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
185 $n = $spline10[$i-10];
186 - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
187 + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
188 } else {
189 my $n = (1-$spline20[$i-10]) * 100;
190 - system("ppmshift $n junk2$$.ppm >junk3$$.ppm");
191 + system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
193 } elsif ($mode eq $RELIEF) {
194 if ($i == 1) {
195 - system("ppmrelief junk1$$.ppm >junk1r$$.ppm");
196 + system("ppmrelief $tmpdir/junk1$$.ppm >$tmpdir/junk1r$$.ppm");
198 if ($i <= 10) {
199 my $n = $spline10[$i];
200 - system("ppmmix $n junk1$$.ppm junk1r$$.ppm >junk3$$.ppm");
201 + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1r$$.ppm >$tmpdir/junk3$$.ppm");
202 } elsif ($i <= 20) {
203 my $n = $spline10[$i-10];
204 - system("ppmmix $n junk1r$$.ppm junk2r$$.ppm >junk3$$.ppm");
205 + system("ppmmix $n $tmpdir/junk1r$$.ppm $tmpdir/junk2r$$.ppm >$tmpdir/junk3$$.ppm");
206 } else {
207 my $n = $spline10[$i-20];
208 - system("ppmmix $n junk2r$$.ppm junk2$$.ppm >junk3$$.ppm");
209 + system("ppmmix $n $tmpdir/junk2r$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
211 if ($i == 10) {
212 - system("ppmrelief junk2$$.ppm >junk2r$$.ppm");
213 + system("ppmrelief $tmpdir/junk2$$.ppm >$tmpdir/junk2r$$.ppm");
215 } elsif ($mode eq $OIL) {
216 if ($i == 1) {
217 - system("ppmtopgm junk1$$.ppm | pgmoil >junko$$.ppm");
218 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
219 - ">junk1o$$.ppm");
220 + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
221 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
222 + ">$tmpdir/junk1o$$.ppm");
224 if ($i <= 10) {
225 my $n = $spline10[$i];
226 - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
227 + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
228 } elsif ($i <= 20) {
229 my $n = $spline10[$i-10];
230 - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
231 + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
232 } else {
233 my $n = $spline10[$i-20];
234 - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
235 + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
237 if ($i == 10) {
238 - system("ppmtopgm junk2$$.ppm | pgmoil >junko$$.ppm");
239 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
240 - ">junk2o$$.ppm");
241 + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
242 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
243 + ">$tmpdir/junk2o$$.ppm");
245 } elsif ($mode eq $EDGE) {
246 if ($i == 1) {
247 - system("ppmtopgm junk1$$.ppm | pgmedge >junko$$.ppm");
248 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
249 - ">junk1o$$.ppm");
250 + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
251 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
252 + ">$tmpdir/junk1o$$.ppm");
254 if ($i <= 10) {
255 my $n = $spline10[$i];
256 - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
257 + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
258 } elsif ($i <= 20) {
259 my $n = $spline10[$i-10];
260 - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
261 + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
262 } else {
263 my $n = $spline10[$i-20];
264 - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
265 + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
267 if ($i == 10) {
268 - system("ppmtopgm junk2$$.ppm | pgmedge >junko$$.ppm");
269 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
270 - ">junk2o$$.ppm");
271 + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
272 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
273 + ">$tmpdir/junk2o$$.ppm");
275 } elsif ($mode eq $BENTLEY) {
276 if ($i == 1) {
277 - system("ppmtopgm junk1$$.ppm | pgmbentley >junko$$.ppm");
278 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
279 - ">junk1o$$.ppm");
280 + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
281 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
282 + ">$tmpdir/junk1o$$.ppm");
284 if ($i <= 10) {
285 my $n = $spline10[$i];
286 - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
287 + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
288 } elsif ($i <= 20) {
289 my $n = $spline10[$i-10];
290 - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
291 + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
292 } else {
293 my $n = $spline10[$i-20];
294 - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
295 + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
297 if ($i == 10) {
298 - system("ppmtopgm junk2$$.ppm | pgmbentley >junko$$.ppm");
299 - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
300 - ">junk2o$$.ppm");
301 + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
302 + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
303 + ">$tmpdir/junk2o$$.ppm");
305 } elsif ($mode eq $BLOCK) {
306 if ($i <= 10) {
307 my $n = 1 - 1.9*$spline20[$i];
308 - system("pamscale $n junk1$$.ppm | " .
309 - "pamscale -width $width -height $height >junk3$$.ppm");
310 + system("pamscale $n $tmpdir/junk1$$.ppm | " .
311 + "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
312 } elsif ($i <= 20) {
313 my $n = $spline10[$i-10];
314 - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
315 + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
316 } else {
317 my $n = 1 - 1.9*$spline20[31-$i];
318 - system("pamscale $n junk2$$.ppm | " .
319 - "pamscale -width $width -height $height >junk3$$.ppm");
320 + system("pamscale $n $tmpdir/junk2$$.ppm | " .
321 + "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
323 if ($i == 10) {
324 - system("cp", "junk3$$.ppm", "junk1a$$.ppm");
325 - system("pamscale $n junk2$$.ppm | " .
326 - "pamscale -width $width -height $height >junk2a$$.ppm");
327 + system("cp", "$tmpdir/junk3$$.ppm", "$tmpdir/junk1a$$.ppm");
328 + system("pamscale $n $tmpdir/junk2$$.ppm | " .
329 + "pamscale -width $width -height $height >$tmpdir/junk2a$$.ppm");
331 } elsif ($mode eq $MIX) {
332 my $fade_factor = sqrt(1/($nframes-$i+1));
333 - system("ppmmix $fade_factor junk1$$.ppm junk2$$.ppm >junk3$$.ppm");
334 + system("ppmmix $fade_factor $tmpdir/junk1$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
335 } else {
336 print("Internal error: impossible mode value '$mode'\n");
339 my $outfile = sprintf("%s.%04d.ppm", $base_name, $i);
340 - system("cp", "junk3$$.ppm", $outfile);
341 + system("cp", "$tmpdir/junk3$$.ppm", $outfile);
345 # Clean up shop.
347 -system("rm junk*$$.ppm");
348 +system("rm $tmpdir/junk*$$.ppm");
350 exit(0);
351 diff --git a/editor/ppmshadow b/editor/ppmshadow
352 index 62cdf8b..72e1b22 100755
353 --- a/editor/ppmshadow
354 +++ b/editor/ppmshadow
355 @@ -97,9 +97,10 @@ sub makeConvolutionKernel($$) {
358 my $tmpdir = $ENV{TMPDIR} || "/tmp";
359 -my $ourtmp = "$tmpdir/ppmshadow$$";
360 -mkdir($ourtmp, 0777) or
361 - die("Unable to create directory for temporary files '$ourtmp");
362 +my $ourtmp; chomp($ourtmp = `mktemp -d -t PPMshadow.XXXXXX`);
363 +if ($? >> 8) {
364 + die "Can't create directory for temporary files";
367 # Process command line options