netpbm-security-scripts.patch 16 KB

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