Tarsnap / spiped

Spiped is a utility for creating symmetrically encrypted and authenticated pipes between socket addresses.
http://www.tarsnap.com/spiped.html
Other
858 stars 56 forks source link

Give an error for addresses lacking a hostname #408

Open gperciva opened 3 months ago

gperciva commented 3 months ago

A source or destination address of the form ":1234" is parsed as a hostname of "" which is guaranteed to never work. While we don't want to give special error messages for all possible invalid addresses, this particular case can easily be produced from a broken shell script (with a hostname variable accidentally not set), so it's worth having a special error message.

Suggested by: Ross Richardson

gperciva commented 3 months ago

This is an alternate solution to #407. (The commit message was tweaked accordingly.)

gperciva commented 3 months ago

Examples of message:

$ ./spipe/spipe -t ":1234" -k /dev/null
spipe: No hostname in ":1234"
spipe: Error resolving socket address: :1234
$ ./spipe/spipe -t :1234 -k /dev/null
spipe: No hostname in ":1234"
spipe: Error resolving socket address: :1234
cperciva commented 3 months ago

Ok, this adds a more helpful error message, but doesn't solve the problem that spiped -e -s '[127.0.0.1]:12345' -t ':12346' -k /COPYRIGHT -D daemonizes before it performs a DNS lookup and then spews error messages forever.

Can you write a sock_validate function which checks if an address is syntactically valid (i.e. if it might work) without actually doing the address resolution? Then we can call that from spiped.

gperciva commented 3 months ago

Oh! Oops, ok, I get it now. Will do.

gperciva commented 3 months ago

Updated.

I also added a check for opt_b.