GraphicsMagick bug fix

Bob Friesenhahn <[email protected]> Fri, 26 Mar 2004 18:20:52 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.announce
Message-ID <Pine.GSO.4.44.0403261801260.11186-100000@scooby.simplesystems.org>
A potentially serious bug was discovered which impacts all
GraphicsMagick releases in the 1.0.X series.  The bug is that only a
small set of temporary file names may be used on systems where the
value of RAND_MAX*62 exceeds the range of an int (2,147,483,647).
This causes an overflow condition which may diminish the number of
temporary file names generated.

While temporary file usage is secure in GraphicsMagick, if there are
very many temporary files in use (e.g. in server environments
processing Postscript files), operations may fail which would
otherwise have succeeded.

If the value of RAND_MAX is greater than 34,636,833 on your system
(this includes Windows, FreeBSD, and Linux, but not Sun Solaris), the
solution is to update your GraphicsMagick sources with the following
patch.

Index: tempfile.c
===================================================================
RCS file: /GraphicsMagick/GraphicsMagick/magick/tempfile.c,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- tempfile.c	16 Apr 2003 22:43:40 -0000	1.13
+++ tempfile.c	24 Mar 2004 02:28:01 -0000	1.13.2.1
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003, 2004 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -131,7 +131,14 @@
   for (c=name; *c; c++)
     {
       if (*c == 'X')
-        *c=SafeChars[((sizeof(SafeChars)-1)*rand())/RAND_MAX];
+        {
+          unsigned int
+            index;
+
+          index=(unsigned int) (((double) (sizeof(SafeChars)-1)*rand())/
+                                RAND_MAX+0.5);
+          *c=SafeChars[index];
+        }
     }
 }


======================================
Bob Friesenhahn
[email protected]
http://www.simplesystems.org/users/bfriesen



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click