Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: How do you get IO::Uncompress::Gunzip to error if the input file isn't a GZ file?

by afoken (Canon)
on Jun 20, 2020 at 14:20 UTC ( #11118271=note: print w/replies, xml ) Need Help??


in reply to Re: How do you get IO::Uncompress::Gunzip to error if the input file isn't a GZ file?
in thread 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.

... but you should remember that this creates a TOCTTOU vulnerability. Also, magic checks check only for magic numbers, not for validity.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^2: How do you get IO::Uncompress::Gunzip to error if the input file isn't a GZ file?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-12-05 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?