orrupted Images/Files can not be placed in albums on multi-upload - ImageMagick orrupted Images/Files can not be placed in albums on multi-upload - ImageMagick
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

orrupted Images/Files can not be placed in albums on multi-upload - ImageMagick

Started by kridenour, June 10, 2005, 08:41:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kridenour

I have seen these errors reported elsewhere on this board, but I didn't find instructions that solved the problems for me.

I have had a Coppermine Gallery v. 1.3 running successfully for more than a year. I moved the domain to a new server, and started getting a variety of errors (detailed below). I upgraded to 1.3.3, which didn't have any effect.

We do have other applications that use ImageMagick and they are all working properly on this server, using both the convert and mogrify commands. Some of the applications (written by us) have very similar functions as Coppermine -- i.e. they upload, resize, create thumbnails. We only have ImageMagick errors with Coppermine, not with any other application.

Here are the details:
-------------------------------------

Current Environment: (past/working environment in parentheses)
Redhat Linux 3.0ES  (Redhat Linux 2.1AS)
Apache 2.0.46     (1.3.27)
Coppermine 1.3.3    (1.3.0)
mySQL 4.0.24    (3.23.58)
PHP 4.3.10     (4.1.2)
ImageMagick 6.2.3   (5.3-8)
GD 2.0.28    (1.6.2)

Test installation (fresh install): http://www.ozarkvacation.com/coppermine (uname=test, pw=test)

------------------------------------

ERRORS:

with ImageMagick
Single file upload works with jpeg (no error output) but it produces a corrupted image and thumbnail.

We've tried photos from various cameras and graphics apps and they all produce the same results. The same photos that can be uploaded/resized/thumbnailed properly in our other ImageMagick apps produce the following errors in Coppermine.

output in server error log:
convert: Corrupt JPEG data: 32525 extraneous bytes before marker 0xd9 `albums/userpics/10001/heron.jpg'.

output in php error log:
PHP Warning:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in /**path/coppermine/include/picmgmt.inc.php on line 187
PHP Warning:  imagecreatefromjpeg(): './albums/edit/mHTTP_temp_7275bcd6.jpg' is not a valid JPEG file in /**path/coppermine/include/picmgmt.inc.php on line 187
PHP Warning:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in /**path/coppermine/include/picmgmt.inc.php on line 187
PHP Warning:  imagecreatefromjpeg(): 'albums/userpics/10001/geese-sign.jpg' is not a valid JPEG file in /**path/coppermine/include/picmgmt.inc.php on line 187

---------------------------------------

With multiple file uploads, the first message is:

1 uploads were successful.
Please click 'Continue' to add the files to albums.

a corrupted image is uploaded, no thumbnail created

When I attempt to put the image in an album, on the next screen, I get this message:

The previous file could not be placed.
You have successfully placed all the files.

output in server error log:
Corrupt JPEG data: premature end of data segment
Invalid JPEG file structure: two SOI markers
Corrupt JPEG data: bad Huffman code
Corrupt JPEG data: premature end of data segment
Invalid JPEG file structure: two SOI markers
Corrupt JPEG data: 28064 extraneous bytes before marker 0xd9
convert: Invalid JPEG file structure: two SOI markers `./albums/edit/mHTTP_temp_24dbe615.jpg'.
[Fri Jun 10 11:35:20 2005] [error] [client 69.152.200.137] File does not exist: /home/allozarks/www.ozarkvacation.com/htdocs/coppermine/albums/edit/preview_ea917d61.jpg, referer: http://www.ozarkvacation.com/coppermine/upload.php
convert: Invalid JPEG file structure: two SOI markers `albums/userpics/10001/geese-sign.jpg'.

no php error reported in the php error log

------------------------------------

Just for comparison, this is a file uploaded via Coppermine:
http://www.ozarkvacation.com/coppermine/displayimage.php?album=random&cat=0&pos=-1

This is the same file, uploaded via one of our scripts. We get the same result using exec(convert) or exec(mogrify):
http://www.ozarkvacation.com/calendar/?eid=1484&day=8&mon=1&yea=2005&mode=event


GD (1 or 2) doesn't work either. I have the error output for those options as well, but no comparable script to see if the functions are working in other scripts besides Coppermine.

Thank you for whatever help you can provide.

Joachim Müller

Hm, I must confess I have no idea. You posted a very good support request that contained all the data needed, yet I have no idea what the problem should be. Have you tried FTP-upload plus batch-add as well?

kridenour

Thanks for your prompt reply! We wandered off and solved this problem. Coppermine is innocent. The problem was Apache 2.0 mangling post data.

---------------------------
FIX:
Apache 2* has a new set of configuration files in a directory called conf.d. In my installation, the relevant file is:

/etc/httpd/conf.d/php.conf

These lines need to be commented out:

#<Files *.php>
#    SetOutputFilter PHP
#    SetInputFilter PHP
#    LimitRequestBody 524288
#</Files>

This is an article explaining why: http://bugs.php.net/bug.php?id=19263

--------------------------

SYMPTOMS & TEST:   

Besides the problems mentioned in the post above, we also noticed that uploaded files were getting larger. We put this line at approximately line #263 in db_input.php to see what was happening (this stops process at the file upload):


     die('here is what you loaded: <a href="http://www.domain.com/coppermine_directory/'.$uploaded_pic.'" target="_blank">'.$uploaded_pic.'</a><br>(no resizing or other processing was applied yet)');        

The "die" line goes above this code in db_input.php:

// Change file permission
       chmod($uploaded_pic, octdec($CONFIG['default_file_mode']));
       // Get picture information

When we looked at the output, we realized that the uploaded file itself was mangled, so ImageMagick and GD had invalid files to work with. That's why all the errors appeared in the log files; the jpeg actually was invalid.

We had the same problem with other scripts that use $HTTP_POST_FILE or $_FILE, so it looks like this is going to be an Apache 2.* issue that will need to be fixed for Coppermine or any other script that uses those variables.

(Note: the test installation referenced above has been removed. Live version is here: www.ozarkvacation.com/gallery)