in reply to Re^3: prevent arbitrary code execution in images
in thread prevent arbitrary code execution in images

Convert JPGs to PNGs and back? If the conversion tool doesn't give an error, it will surely corrupt the virus. (Discard the file if the conversion tool gives an error.)

That's not a bad idea. My only concern is that, since JPEG's a lossy format, re-JPEGging an image might introduce more compression artifacts. In that case, you might want to leave the image as a PNG. (I can't offhand think of any reason why you'd want to use JPEG instead of PNG... I think the compression rates are pretty similar these days.)

--
F o x t r o t U n i f o r m
Found a typo in this node? /msg me
% man 3 strfry

  • Comment on Re^4: prevent arbitrary code execution in images

Replies are listed 'Best First'.
Re^5: prevent arbitrary code execution in images
by pingo (Hermit) on Sep 16, 2004 at 10:09 UTC
    Out of curiosity, I tried converting two jpegs to pngs (using convert). One of them became four times bigger, the other one nine times bigger.

    (BTW, I also tried converting the same jpegs to gifs, and they became five and six times larger.)
      You discard the conversion output. You just want to know if it worked or not. Like a regex without parens, the only thing you're looking for is metadata.

      --
      Spring: Forces, Coiled Again!