@@ -461,33 +461,36 @@ char *
461461nc_server_unix_get_socket_path (const struct nc_endpt * endpt )
462462{
463463 LY_ARRAY_COUNT_TYPE i ;
464- const char * filename = NULL ;
464+ const char * p = NULL ;
465465 char * path = NULL ;
466466
467467 /* check the endpoints options for type of socket path */
468468 if (endpt -> opts .unix -> path_type == NC_UNIX_SOCKET_PATH_FILE ) {
469469 /* UNIX socket endpoints always have only one bind, get its address */
470- filename = endpt -> binds [0 ].address ;
470+ p = endpt -> binds [0 ].address ;
471+
472+ /* it is relative, we need to construct the full path */
473+ if (nc_session_unix_construct_socket_path (p , & path )) {
474+ return NULL ;
475+ }
471476 } else if (endpt -> opts .unix -> path_type == NC_UNIX_SOCKET_PATH_HIDDEN ) {
472- /* search the mappings */
477+ /* search the mappings, no need to construct the path */
473478 LY_ARRAY_FOR (server_opts .unix_paths , i ) {
474479 if (!strcmp (server_opts .unix_paths [i ].endpt_name , endpt -> name )) {
475- filename = server_opts .unix_paths [i ].path ;
480+ p = server_opts .unix_paths [i ].path ;
476481 break ;
477482 }
478483 }
479- if (!filename ) {
484+ if (!p ) {
480485 ERR (NULL , "UNIX socket path mapping for endpoint \"%s\" not found." , endpt -> name );
481486 }
487+
488+ path = strdup (p );
489+ NC_CHECK_ERRMEM_RET (!path , NULL );
482490 } else {
483491 ERRINT ;
484492 }
485493
486- /* construct the full socket path */
487- if (nc_session_unix_construct_socket_path (filename , & path )) {
488- return NULL ;
489- }
490-
491494 return path ;
492495}
493496
0 commit comments