Skip to content

Commit

Permalink
Invoke usage for missing hostnames in -[st]
Browse files Browse the repository at this point in the history
A source or destination address of the form ":1234" is parsed as a
hostname of "" which is guaranteed to never work.  While we can't
reject all possible invalid addresses at this point -- and probably
shouldn't since the resolver can give more informative errors --
this particular case can easily be produced from a broken shell
script (with a hostname variable accidentally not set), so it's more
worthy of rejection via usage() than most.

Suggested by:	Ross Richardson
  • Loading branch information
cperciva committed Aug 3, 2024
1 parent 91d899b commit 0fa0b88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spipe/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ main(int argc, char * argv[])
usage();
if (!(opt_o > 0.0))
usage();
if (opt_t == NULL)
if ((opt_t == NULL) || (opt_t[0] == ':'))
usage();

/* Initialize the "events & threads" cookie. */
Expand Down
4 changes: 2 additions & 2 deletions spiped/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ main(int argc, char * argv[])
usage();
if ((opt_r != 60.0) && opt_R)
usage();
if (opt_s == NULL)
if ((opt_s == NULL) || (opt_s[0] == ':'))
usage();
if (opt_t == NULL)
if ((opt_t == NULL) || (opt_t[0] == ':'))
usage();

/*
Expand Down

0 comments on commit 0fa0b88

Please sign in to comment.