netpbm-security-scripts.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. @@ -537,12 +534,17 @@ typeDescription=`file "$file" | cut -d: -f2- | cut -c2-`
  6. determineType "$file" "$mimeType" "$typeDescription" "$fileExtension"
  7. if [ "$filetype" = "unknown" ]; then
  8. - echo "$progname: unknown file type. " \
  9. - "'file' says mime type is '$mimeType', " 1>&2
  10. - echo "type description is '$typeDescription'" 1>&2
  11. + if [ -d "$tempdir" ] ; then
  12. + rm -rf "$tempdir"
  13. + fi
  14. +
  15. exit 1
  16. fi
  17. convertIt $file $filetype
  18. +if [ -d "$tempdir" ] ; then
  19. + rm -rf "$tempdir"
  20. +fi
  21. +
  22. exit 0
  23. diff --git a/editor/pnmmargin b/editor/pnmmargin
  24. index 0f57d1d..e0d3625 100755
  25. --- a/editor/pnmmargin
  26. +++ b/editor/pnmmargin
  27. @@ -90,6 +86,7 @@ else
  28. -white | -black )
  29. pnmpad $plainopt $color \
  30. -left=$size -right=$size -top=$size -bottom=$size $tmp1
  31. + rm -rf "$tempdir"
  32. exit
  33. ;;
  34. * )
  35. @@ -103,4 +100,4 @@ else
  36. pnmcat -tb $plainopt $tmp3 $tmp4 $tmp3
  37. fi
  38. -
  39. +rm -rf "$tempdir"
  40. diff --git a/editor/ppmfade b/editor/ppmfade
  41. index 027fc79..8eb094f 100755
  42. --- a/editor/ppmfade
  43. +++ b/editor/ppmfade
  44. @@ -40,6 +40,7 @@ exec perl -w -x -S -- "$0" "$@"
  45. #
  46. ##############################################################################
  47. use strict;
  48. +use File::Temp "tempdir";
  49. my $SPREAD = 1;
  50. my $SHIFT = 2;
  51. @@ -137,20 +138,26 @@ if ($first_file ne "undefined") {
  52. print("Frames are " . $width . "W x " . $height . "H\n");
  53. +#
  54. +# We create a tmp-directory right here
  55. +#
  56. +my $tmpdir = tempdir("ppmfade.XXXXXX", CLEANUP => 1);
  57. +
  58. +
  59. if ($first_file eq "undefined") {
  60. print "Fading from black to ";
  61. - system("ppmmake \\#000 $width $height >junk1$$.ppm");
  62. + system("ppmmake \\#000 $width $height >$tmpdir/junk1$$.ppm");
  63. } else {
  64. print "Fading from $first_file to ";
  65. - system("cp", $first_file, "junk1$$.ppm");
  66. + system("cp", $first_file, "$tmpdir/junk1$$.ppm");
  67. }
  68. if ($last_file eq "undefined") {
  69. print "black.\n";
  70. - system("ppmmake \\#000 $width $height >junk2$$.ppm");
  71. + system("ppmmake \\#000 $width $height >$tmpdir/junk2$$.ppm");
  72. } else {
  73. print "$last_file\n";
  74. - system("cp", $last_file, "junk2$$.ppm");
  75. + system("cp", $last_file, "$tmpdir/junk2$$.ppm");
  76. }
  77. #
  78. @@ -158,14 +165,14 @@ if ($last_file eq "undefined") {
  79. #
  80. # Here's what our temporary files are:
  81. -# junk1$$.ppm: The original (fade-from) image
  82. -# junk2$$.ppm: The target (fade-from) image
  83. -# junk3$$.ppm: The frame of the fade for the current iteration of the
  84. -# the for loop.
  85. -# junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
  86. -# image to another, this is the first frame of that
  87. -# sequence.
  88. -# junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
  89. +# $tmpdir/junk1$$.ppm: The original (fade-from) image
  90. +# $tmpdir/junk2$$.ppm: The target (fade-from) image
  91. +# $tmpdir/junk3$$.ppm: The frame of the fade for the current iteration of the
  92. +# the for loop.
  93. +# $tmpdir/junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
  94. +# image to another, this is the first frame of that
  95. +# sequence.
  96. +# $tmpdir/junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
  97. my $i; # Frame number
  98. for ($i = 1; $i <= $nframes; $i++) {
  99. @@ -173,147 +180,147 @@ for ($i = 1; $i <= $nframes; $i++) {
  100. if ($mode eq $SPREAD) {
  101. if ($i <= 10) {
  102. my $n = $spline20[$i] * 100;
  103. - system("ppmspread $n junk1$$.ppm >junk3$$.ppm");
  104. + system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
  105. } elsif ($i <= 20) {
  106. my $n;
  107. $n = $spline20[$i] * 100;
  108. - system("ppmspread $n junk1$$.ppm >junk1a$$.ppm");
  109. + system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
  110. $n = (1-$spline20[$i-10]) * 100;
  111. - system("ppmspread $n junk2$$.ppm >junk2a$$.ppm");
  112. + system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
  113. $n = $spline10[$i-10];
  114. - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
  115. + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
  116. } else {
  117. my $n = (1-$spline20[$i-10])*100;
  118. - system("ppmspread $n junk2$$.ppm >junk3$$.ppm");
  119. + system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  120. }
  121. } elsif ($mode eq $SHIFT) {
  122. if ($i <= 10) {
  123. my $n = $spline20[$i] * 100;
  124. - system("ppmshift $n junk1$$.ppm >junk3$$.ppm");
  125. + system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
  126. } elsif ($i <= 20) {
  127. my $n;
  128. $n = $spline20[$i] * 100;
  129. - system("ppmshift $n junk1$$.ppm >junk1a$$.ppm");
  130. + system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
  131. $n = (1-$spline20[$i-10])*100;
  132. - system("ppmshift $n junk2$$.ppm >junk2a$$.ppm");
  133. + system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
  134. $n = $spline10[$i-10];
  135. - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
  136. + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
  137. } else {
  138. my $n = (1-$spline20[$i-10]) * 100;
  139. - system("ppmshift $n junk2$$.ppm >junk3$$.ppm");
  140. + system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  141. }
  142. } elsif ($mode eq $RELIEF) {
  143. if ($i == 1) {
  144. - system("ppmrelief junk1$$.ppm >junk1r$$.ppm");
  145. + system("ppmrelief $tmpdir/junk1$$.ppm >$tmpdir/junk1r$$.ppm");
  146. }
  147. if ($i <= 10) {
  148. my $n = $spline10[$i];
  149. - system("ppmmix $n junk1$$.ppm junk1r$$.ppm >junk3$$.ppm");
  150. + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1r$$.ppm >$tmpdir/junk3$$.ppm");
  151. } elsif ($i <= 20) {
  152. my $n = $spline10[$i-10];
  153. - system("ppmmix $n junk1r$$.ppm junk2r$$.ppm >junk3$$.ppm");
  154. + system("ppmmix $n $tmpdir/junk1r$$.ppm $tmpdir/junk2r$$.ppm >$tmpdir/junk3$$.ppm");
  155. } else {
  156. my $n = $spline10[$i-20];
  157. - system("ppmmix $n junk2r$$.ppm junk2$$.ppm >junk3$$.ppm");
  158. + system("ppmmix $n $tmpdir/junk2r$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  159. }
  160. if ($i == 10) {
  161. - system("ppmrelief junk2$$.ppm >junk2r$$.ppm");
  162. + system("ppmrelief $tmpdir/junk2$$.ppm >$tmpdir/junk2r$$.ppm");
  163. }
  164. } elsif ($mode eq $OIL) {
  165. if ($i == 1) {
  166. - system("ppmtopgm junk1$$.ppm | pgmoil >junko$$.ppm");
  167. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  168. - ">junk1o$$.ppm");
  169. + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
  170. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  171. + ">$tmpdir/junk1o$$.ppm");
  172. }
  173. if ($i <= 10) {
  174. my $n = $spline10[$i];
  175. - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
  176. + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
  177. } elsif ($i <= 20) {
  178. my $n = $spline10[$i-10];
  179. - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
  180. + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
  181. } else {
  182. my $n = $spline10[$i-20];
  183. - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
  184. + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  185. }
  186. if ($i == 10) {
  187. - system("ppmtopgm junk2$$.ppm | pgmoil >junko$$.ppm");
  188. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  189. - ">junk2o$$.ppm");
  190. + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
  191. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  192. + ">$tmpdir/junk2o$$.ppm");
  193. }
  194. } elsif ($mode eq $EDGE) {
  195. if ($i == 1) {
  196. - system("ppmtopgm junk1$$.ppm | pgmedge >junko$$.ppm");
  197. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  198. - ">junk1o$$.ppm");
  199. + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
  200. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  201. + ">$tmpdir/junk1o$$.ppm");
  202. }
  203. if ($i <= 10) {
  204. my $n = $spline10[$i];
  205. - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
  206. + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
  207. } elsif ($i <= 20) {
  208. my $n = $spline10[$i-10];
  209. - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
  210. + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
  211. } else {
  212. my $n = $spline10[$i-20];
  213. - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
  214. + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  215. }
  216. if ($i == 10) {
  217. - system("ppmtopgm junk2$$.ppm | pgmedge >junko$$.ppm");
  218. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  219. - ">junk2o$$.ppm");
  220. + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
  221. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  222. + ">$tmpdir/junk2o$$.ppm");
  223. }
  224. } elsif ($mode eq $BENTLEY) {
  225. if ($i == 1) {
  226. - system("ppmtopgm junk1$$.ppm | pgmbentley >junko$$.ppm");
  227. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  228. - ">junk1o$$.ppm");
  229. + system("ppmtopgm $tmpdir/junk1$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
  230. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  231. + ">$tmpdir/junk1o$$.ppm");
  232. }
  233. if ($i <= 10) {
  234. my $n = $spline10[$i];
  235. - system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
  236. + system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
  237. } elsif ($i <= 20) {
  238. my $n = $spline10[$i-10];
  239. - system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
  240. + system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
  241. } else {
  242. my $n = $spline10[$i-20];
  243. - system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
  244. + system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  245. }
  246. if ($i == 10) {
  247. - system("ppmtopgm junk2$$.ppm | pgmbentley >junko$$.ppm");
  248. - system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
  249. - ">junk2o$$.ppm");
  250. + system("ppmtopgm $tmpdir/junk2$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
  251. + system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
  252. + ">$tmpdir/junk2o$$.ppm");
  253. }
  254. } elsif ($mode eq $BLOCK) {
  255. if ($i <= 10) {
  256. my $n = 1 - 1.9*$spline20[$i];
  257. - system("pamscale $n junk1$$.ppm | " .
  258. - "pamscale -width $width -height $height >junk3$$.ppm");
  259. + system("pamscale $n $tmpdir/junk1$$.ppm | " .
  260. + "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
  261. } elsif ($i <= 20) {
  262. my $n = $spline10[$i-10];
  263. - system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
  264. + system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
  265. } else {
  266. my $n = 1 - 1.9*$spline20[31-$i];
  267. - system("pamscale $n junk2$$.ppm | " .
  268. - "pamscale -width $width -height $height >junk3$$.ppm");
  269. + system("pamscale $n $tmpdir/junk2$$.ppm | " .
  270. + "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
  271. }
  272. if ($i == 10) {
  273. - system("cp", "junk3$$.ppm", "junk1a$$.ppm");
  274. - system("pamscale $n junk2$$.ppm | " .
  275. - "pamscale -width $width -height $height >junk2a$$.ppm");
  276. + system("cp", "$tmpdir/junk3$$.ppm", "$tmpdir/junk1a$$.ppm");
  277. + system("pamscale $n $tmpdir/junk2$$.ppm | " .
  278. + "pamscale -width $width -height $height >$tmpdir/junk2a$$.ppm");
  279. }
  280. } elsif ($mode eq $MIX) {
  281. my $fade_factor = sqrt(1/($nframes-$i+1));
  282. - system("ppmmix $fade_factor junk1$$.ppm junk2$$.ppm >junk3$$.ppm");
  283. + system("ppmmix $fade_factor $tmpdir/junk1$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
  284. } else {
  285. print("Internal error: impossible mode value '$mode'\n");
  286. }
  287. my $outfile = sprintf("%s.%04d.ppm", $base_name, $i);
  288. - system("cp", "junk3$$.ppm", $outfile);
  289. + system("cp", "$tmpdir/junk3$$.ppm", $outfile);
  290. }
  291. #
  292. # Clean up shop.
  293. #
  294. -system("rm junk*$$.ppm");
  295. +system("rm $tmpdir/junk*$$.ppm");
  296. exit(0);