From 0f596853478db074200ec00a40579614d6cc93cc Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 7 Aug 2024 19:54:44 -0700 Subject: [PATCH] Use sock_addr_validate() 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 --- spipe/main.c | 3 ++- spiped/main.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spipe/main.c b/spipe/main.c index 6f35141d..32353c3a 100644 --- a/spipe/main.c +++ b/spipe/main.c @@ -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" @@ -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. */ diff --git a/spiped/main.c b/spiped/main.c index d3efe7a8..a51b5153 100644 --- a/spiped/main.c +++ b/spiped/main.c @@ -13,6 +13,7 @@ #include "parsenum.h" #include "setuidgid.h" #include "sock.h" +#include "sock_util.h" #include "warnp.h" #include "dispatch.h" @@ -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(); /*