Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Dan Switzer / Dan Switzer (Dan Switzer)
Created: 06/08/2012
Components: CFIMAGE
Versions: 9.0.1
Failure Type: Crash
Found In Build/Fixed In Build: 9.0.1 /
Priority/Frequency: Critical / All users will encounter
Locale/System: English / Win 2003 Server
Vote Count: 0
Problem Description:
Certain image files (such as the attached PNG) can cause the ColdFusion server to crash when it tries to write the file to disk.
When you read in the attached "bad.png" file using imageRead(), it reads the image into memory without any issues. However, any functions to manipulate the image are extremely slow and any attempt to write to disk using imageWrite() causes the server to crash.
This problem may be related to:
http://blog.dkferguson.com/index.cfm/2010/12/1/ColdFusion-9-PNG-image-processing
(At least the fix is the same.)
Steps to Reproduce:
Run the example.cfm and select the "Crash server" link. This will run crash the server when it tries to resize the image into a thumbnail.
The basic code is:
// read in the image
thumbnail = imageRead(source);
// resize the thumbnail
imageScaleToFit(thumbnail, width, height, interpolation);
// save the thumbnail
imageWrite(thumbnail, destination, quality);
Actual Result:
Server crashes with a 0-byte file being created.
Expected Result:
I would expected the resized image to be created.
Any Workarounds:
The workaround is to save the file as a BMP first (or JPG) and then re-read the image into memory. Try re-running the example.cfm, but this time click on the "Run test w/JPGHack fix" link. This will run the following additional logic, which converts the image to a BMP before resizing and saving the thumbnail.
// for ColdFusion 9 and above, use the RAM disk for the conversion
if( val(server.ColdFusion.ProductVersion) gte 9 ){
bitmap = "ram://" & randRange(11111, 99999) & "_" & reReplaceNoCase(getFileFromPath(source), "\.\w+$", ".bmp");
} else {
bitmap = replace(getTempFile(getTempDirectory(), "thb"), ".tmp", ".bmp");
}
// save the image as a BMP
imageWrite(thumbnail, bitmap, true, 1);
// read in the BMP
thumbnail = imageRead(bitmap);
// remove the temp file
fileDelete(bitmap);
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3209431
External Customer Info:
External Company:
External Customer Name: Dan G. Switzer, II
External Customer Email:
External Test Config: My Hardware and Environment details:
I've tested this on a couple of different environments w/different hardware, but all were running some version of Windows Server 2003 on 32-bit hardware.
Attachments:
- June 08, 2012 00:00:00: 1_bad_image.zip
Comments: