> -----Original Message-----
> From: Richard Cochran <richardcoch...@gmail.com>
> Sent: Monday, September 4, 2023 11:21 AM
> To: linuxptp-devel@lists.sourceforge.net
> Subject: [Linuxptp-devel] [PATCH] phc2sys: Avoid segfault with default UDS
> address.
> 
> 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>
> ---

Reviewed-by: Jacob Keller <jacob.e.kel...@intel.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


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

Reply via email to