Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent bad image files from causing core dumps #67

Open
kohder opened this issue May 1, 2017 · 2 comments
Open

How to prevent bad image files from causing core dumps #67

kohder opened this issue May 1, 2017 · 2 comments

Comments

@kohder
Copy link

kohder commented May 1, 2017

Getting core dumps whenever gem hits an image file that causes any kind of error. I've tried being defensive by checking all images with the FastImage gem beforehand but now crashing on an image that gets past the FastImage check.

Example:

Premature end of JPEG file
Premature end of JPEG file
convert.im6: JPEG datastream contains no image `/srv/app/pulp/public/uploads/tmp/1493639798-9541-0001-7668/pro_rbmf_15909214.jpg' @ error/jpeg.c/JPEGErrorHandler/316.
convert.im6: no images defined `pnm:-' @ error/convert.c/ConvertImageCommand/3044.
sh: 1: gm: not found
terminate called after throwing an instance of 'cimg_library::CImgIOException'
  what():  [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load() : Failed to recognize format of file '/srv/app/pulp/public/uploads/tmp/1493639798-9541-0001-7668/pro_rbmf_15909214.jpg'.
Aborted (core dumped)

How can I prevent the gem from crashing the Ruby process? A rescue block is not working in this case.

@kohder
Copy link
Author

kohder commented May 1, 2017

FYI, I believe I have fixed this in my fork: https://github.com/BookBub/phashion/commit/57f929892ffa856bb194b065fa4a7eafa5f89c35?w=1

@westonplatter
Copy link
Owner

@kohder glad you got a working solution. I'd be happy to pull those changes in if you think it would make a nice enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants