From dd3ef01a53cbb5724dd453572c5f3f96d40253e6 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Fri, 20 Dec 2024 17:55:20 -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 | 5 ++++- spiped/main.c | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spipe/main.c b/spipe/main.c index 6f35141d..79dc231e 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,9 @@ main(int argc, char * argv[]) usage(); if (!(opt_o > 0.0)) usage(); - if (opt_t == NULL) + if (sock_addr_validate(opt_t)) + usage(); + if (opt_b && sock_addr_validate(opt_b)) usage(); /* Initialize the "events & threads" cookie. */ diff --git a/spiped/main.c b/spiped/main.c index d3efe7a8..fb6e39af 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,11 @@ 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(); + if (opt_b && sock_addr_validate(opt_b)) usage(); /*