Skip to content

Commit

Permalink
Use sock_addr_validate()
Browse files Browse the repository at this point in the history
We want to check that the addresses are syntactically valid before
spiped daemonizes.

It's not strictly necessary for spipe, but we might as well check it so
that we can produce a usage() if necessary.

Suggested by:	Ross Richardson
  • Loading branch information
gperciva committed Aug 8, 2024
1 parent 8fdb3f2 commit 0f59685
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion spipe/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "graceful_shutdown.h"
#include "parsenum.h"
#include "sock.h"
#include "sock_util.h"
#include "warnp.h"

#include "proto_conn.h"
Expand Down Expand Up @@ -221,7 +222,7 @@ main(int argc, char * argv[])
usage();
if (!(opt_o > 0.0))
usage();
if (opt_t == NULL)
if (sock_addr_validate(opt_t))
usage();

/* Initialize the "events & threads" cookie. */
Expand Down
5 changes: 3 additions & 2 deletions spiped/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "parsenum.h"
#include "setuidgid.h"
#include "sock.h"
#include "sock_util.h"
#include "warnp.h"

#include "dispatch.h"
Expand Down Expand Up @@ -239,9 +240,9 @@ main(int argc, char * argv[])
usage();
if ((opt_r != 60.0) && opt_R)
usage();
if (opt_s == NULL)
if (sock_addr_validate(opt_s))
usage();
if (opt_t == NULL)
if (sock_addr_validate(opt_t))
usage();

/*
Expand Down

0 comments on commit 0f59685

Please sign in to comment.