[vlc-commits] control: rc: avoid stringop-truncation warning

Alexandre Janniaux git at videolan.org
Thu Feb 13 12:03:44 CET 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Mon Jan 20 16:44:44 2020 +0100| [27046e964d9096646f6806f43fdcd623f0ea986e] | committer: Jean-Baptiste Kempf

control: rc: avoid stringop-truncation warning

Fortify enabled implies a warning if we use strncpy with a length equal
to the buffer size. As we fill the last item with a null character, we
can use length-1 instead as well.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27046e964d9096646f6806f43fdcd623f0ea986e
---

 modules/control/rc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/control/rc.c b/modules/control/rc.c
index 86ee873030..cdfa70b08c 100644
--- a/modules/control/rc.c
+++ b/modules/control/rc.c
@@ -1738,7 +1738,7 @@ static int Activate( vlc_object_t *p_this )
         }
 
         addr.sun_family = AF_LOCAL;
-        strncpy( addr.sun_path, psz_unix_path, sizeof( addr.sun_path ) );
+        strncpy( addr.sun_path, psz_unix_path, sizeof( addr.sun_path ) - 1 );
         addr.sun_path[sizeof( addr.sun_path ) - 1] = '\0';
 
         if (bind (i_socket, (struct sockaddr *)&addr, sizeof (addr))



More information about the vlc-commits mailing list