Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Untaint IP address/hostname question

by ambrus (Abbot)
on Mar 09, 2004 at 16:31 UTC ( [id://335167]=note: print w/replies, xml ) Need Help??


in reply to Untaint IP address/hostname question

It depends on how you will use the host name. If you convert it directly with gethostbyname (which is the safest solution), you can probably accept any hostname. If you pass it to some external program or shell, you'll have to check what characters that program accepts. The important point here is not to check that the hostname is a valid hostname, but rather that it using it won't do something bad. That is, even if a hostname is valid, it can screw your program if whatever you pass it misinterprets it. If the hostname for example starts with a hyphen (I don't know if that can be valid or not), and you call a program with it and it interprets it as a switch, that's bad, even though the user gave you a valid hostname.

  • Comment on Re: Untaint IP address/hostname question

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found