JP2: JasPer uses tmpnam(), which is broken on Windows
Posted: 2012-08-21T10:25:04-07:00
This is not an IM bug, it's a JasPer bug, but nonetheless read on. FWIW I observe this with IM 6.7.7.
I've been debugging a puzzling permissions-related issue relating to decoding JPEG2000 images, and it seems to be this line in JasPer's jas_stream.c that's the culprit:
/* Choose a file name. */
tmpnam(obj->pathname);
Apaprently, on Windows, tmpnam() always returns a temporary filename in the root directory of the current drive (!), which therefore fails for various users who can't write to the root. (I saw these files being created in my process trace, and after some googling came across this: http://docs.python.org/library/os.html#os.tmpnam)
Various distributions patch around this tmpnam() for other reasons:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506739
https://bugzilla.redhat.com/show_bug.cgi?id=461477
I've reported this to the JasPer maintainer, but perhaps IM ought to patch it too in the meantime? (Ideally, it would use MAGICK_TMPDIR.)
I've been debugging a puzzling permissions-related issue relating to decoding JPEG2000 images, and it seems to be this line in JasPer's jas_stream.c that's the culprit:
/* Choose a file name. */
tmpnam(obj->pathname);
Apaprently, on Windows, tmpnam() always returns a temporary filename in the root directory of the current drive (!), which therefore fails for various users who can't write to the root. (I saw these files being created in my process trace, and after some googling came across this: http://docs.python.org/library/os.html#os.tmpnam)
Various distributions patch around this tmpnam() for other reasons:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506739
https://bugzilla.redhat.com/show_bug.cgi?id=461477
I've reported this to the JasPer maintainer, but perhaps IM ought to patch it too in the meantime? (Ideally, it would use MAGICK_TMPDIR.)