Check that provided path fits into defined buffer. Don't write too many
bytes to avoid having an unterminated string.
Type: fix
Fixes:
31f192434660
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I1ea8b6d6a3474c032e542b6980ed14bac72093a8
struct sockaddr_un saddr = { 0 };
saddr.sun_family = AF_UNIX;
+
+ if (strlen (sock_fname) > sizeof (saddr.sun_path) - 1)
+ {
+ perror ("socket path too long");
+ exit (1);
+ }
+
strncpy (saddr.sun_path, sock_fname, sizeof (saddr.sun_path) - 1);
sock_fd = socket (AF_UNIX, SOCK_STREAM, 0);