@@ -461,26 +461,25 @@ static std::string get_fifo_path() {
461461 return s;
462462}
463463
464- static int get_fifo_path_to_addr (struct sockaddr_un *addr) {
465- int len;
464+ static bool get_fifo_path_to_addr (struct sockaddr_un *addr) {
466465 const std::string s = get_fifo_path ();
467466 if (s.empty ()) {
468- return - 1 ;
467+ return false ;
469468 }
470- if (s.size () + 1 > sizeof (addr->sun_path )) {
469+ if (s.size () + 2 > sizeof (addr->sun_path )) {
471470 rtapi_print_msg (
472471 RTAPI_MSG_ERR,
473472 " rtapi_app: rtapi fifo path is too long (arch limit %zd): %s\n " ,
474473 sizeof (sockaddr_un::sun_path),
475474 s.c_str ()
476475 );
477- return - 1 ;
476+ return false ;
478477 }
479478 // See: https://www.man7.org/linux/man-pages/man7/unix.7.html abstract
480479 // sun_path[0] is a null byte ('\0')
481480 addr->sun_path [0 ]=0 ;
482- len = snprintf (addr->sun_path + 1 , sizeof (addr->sun_path ) - 1 , " %s " , s. c_str () );
483- return len ;
481+ strncpy (addr->sun_path + 1 , s. c_str (), sizeof (addr->sun_path ) - 2 );
482+ return true ;
484483}
485484
486485static double diff_timespec (const struct timespec *time1, const struct timespec *time0) {
@@ -525,7 +524,6 @@ int main(int argc, char **argv) {
525524 }
526525
527526become_master:
528- int len = 0 ;
529527 int fd = socket (PF_UNIX, SOCK_STREAM, 0 );
530528 if (fd == -1 ) {
531529 perror (" socket" );
@@ -537,7 +535,7 @@ int main(int argc, char **argv) {
537535 struct sockaddr_un addr;
538536 memset (&addr, 0x0 , sizeof (addr));
539537 addr.sun_family = AF_UNIX;
540- if ((len = get_fifo_path_to_addr (&addr)) < 0 )
538+ if (! get_fifo_path_to_addr (&addr))
541539 exit (1 );
542540
543541 // plus one because we use the abstract namespace, it will show up in
0 commit comments