@@ -461,13 +461,13 @@ static std::string get_fifo_path() {
461461 return s;
462462}
463463
464- static int get_fifo_path ( char *buf, size_t bufsize ) {
464+ static int get_fifo_path_to_addr ( struct sockaddr_un *addr ) {
465465 int len;
466466 const std::string s = get_fifo_path ();
467467 if (s.empty ()) {
468468 return -1 ;
469469 }
470- if (s.size () + 1 > sizeof (sockaddr_un:: sun_path)) {
470+ if (s.size () + 1 > sizeof (addr-> sun_path )) {
471471 rtapi_print_msg (
472472 RTAPI_MSG_ERR,
473473 " rtapi_app: rtapi fifo path is too long (arch limit %zd): %s\n " ,
@@ -476,7 +476,10 @@ static int get_fifo_path(char *buf, size_t bufsize) {
476476 );
477477 return -1 ;
478478 }
479- len = snprintf (buf + 1 , bufsize - 1 , " %s" , s.c_str ());
479+ // See: https://www.man7.org/linux/man-pages/man7/unix.7.html abstract
480+ // sun_path[0] is a null byte ('\0')
481+ addr->sun_path [0 ]=0 ;
482+ len = snprintf (addr->sun_path + 1 , sizeof (addr->sun_path ) - 1 , " %s" , s.c_str ());
480483 return len;
481484}
482485
@@ -530,7 +533,7 @@ int main(int argc, char **argv) {
530533 struct sockaddr_un addr;
531534 memset (&addr, 0x0 , sizeof (addr));
532535 addr.sun_family = AF_UNIX;
533- if ((len = get_fifo_path ( addr. sun_path , sizeof (addr. sun_path ) )) < 0 )
536+ if ((len = get_fifo_path_to_addr (& addr)) < 0 )
534537 exit (1 );
535538
536539 // plus one because we use the abstract namespace, it will show up in
0 commit comments