The recently added phc2sys multi-domain mode introduced a regression.
In the non-automatic mode (using flag -w to wait for ptp4l) the code
will attempt to set the UDS address using an uninitialized pointer,
unless the -z flag is also specified.

Fix the issue by testing whether the -z flag was present on the
command line before changing the UDS address.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
Reported-by: Trey Harrison <spamfort...@gmail.com>
---
 phc2sys.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 313cdcf..9d8d42f 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1490,7 +1490,10 @@ int main(int argc, char *argv[])
        if (wait_sync) {
                snprintf(uds_local, sizeof(uds_local),
                         "/var/run/phc2sys.%d", getpid());
-               config_set_string(cfg, "uds_address", uds_remotes[0]);
+
+               if (uds_remote_cnt > 0)
+                       config_set_string(cfg, "uds_address",
+                                         uds_remotes[uds_remote_cnt - 1]);
 
                if (init_pmc_node(cfg, domains[0].agent, uds_local,
                                  phc2sys_recv_subscribed, &domains[0]))
-- 
2.39.2



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to