>From aaee5182e0578f0bab0a0b09bce1a2410eda93db Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 22 Feb 2020 10:54:56 +0000 Subject: [PATCH 1/2] server: Check parameters in main (). Unclear why we were checking these parameters in start_serving, except because that's historically how it was always done. Also move some serving-related calls into start_serving. While this slightly changes the order of operations in some corner cases, it's essentially neutral code refactoring. --- server/main.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/server/main.c b/server/main.c index 8aa8b497..3bc59781 100644 --- a/server/main.c +++ b/server/main.c @@ -671,10 +671,25 @@ main (int argc, char *argv[]) /* Select the correct thread model based on config. */ lock_init_thread_model (); - set_up_quit_pipe (); -#if !ENABLE_LIBFUZZER - set_up_signals (); -#endif + /* If the user has mixed up -p/--run/-s/-U/--vsock options, then + * give an error. + * + * XXX Actually the server could easily be extended to handle both + * TCP/IP and Unix sockets, or even multiple TCP/IP ports. + */ + if ((port && unixsocket) || + (port && listen_stdin) || + (unixsocket && listen_stdin) || + (listen_stdin && run) || + (vsock && unixsocket) || + (vsock && listen_stdin) || + (vsock && run)) { + fprintf (stderr, + "%s: -p, --run, -s, -U or --vsock options cannot be used" + "in this combination\n", + program_name); + exit (EXIT_FAILURE); + } start_serving (); @@ -847,25 +862,10 @@ start_serving (void) size_t nr_socks; size_t i; - /* If the user has mixed up -p/--run/-s/-U/--vsock options, then - * give an error. - * - * XXX Actually the server could easily be extended to handle both - * TCP/IP and Unix sockets, or even multiple TCP/IP ports. - */ - if ((port && unixsocket) || - (port && listen_stdin) || - (unixsocket && listen_stdin) || - (listen_stdin && run) || - (vsock && unixsocket) || - (vsock && listen_stdin) || - (vsock && run)) { - fprintf (stderr, - "%s: -p, --run, -s, -U or --vsock options cannot be used" - "in this combination\n", - program_name); - exit (EXIT_FAILURE); - } + set_up_quit_pipe (); +#if !ENABLE_LIBFUZZER + set_up_signals (); +#endif /* Lock the process into memory if requested. */ if (swap) { -- 2.25.0