in reply to How do you get IO::Uncompress::Gunzip to error if the input file isn't a GZ file?
You could use file(1) magic to check if a file is indeed a compressed file before trying to uncompress. For Perl there are File::MMagic and File::LibMagic among other modules to check file MIME type.
You could use file(1) magic to check if a file is indeed a compressed file before trying to uncompress.
... but you should remember that this creates a TOCTTOU vulnerability. Also, magic checks check only for magic numbers, not for validity.
PerlMonks, of course - how could you ask?
Games & puzzles
Arts & music
Whichever pays my bills
Results (242 votes). Check out past polls.