Commit 68fa95cf authored by Ondřej Zajíček's avatar Ondřej Zajíček

Check of socket name length

parent 52586ccd
...@@ -252,6 +252,10 @@ server_connect(void) ...@@ -252,6 +252,10 @@ server_connect(void)
server_fd = socket(AF_UNIX, SOCK_STREAM, 0); server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (server_fd < 0) if (server_fd < 0)
die("Cannot create socket: %m"); die("Cannot create socket: %m");
if (strlen(server_path) >= sizeof(sa.sun_path))
die("server_connect: path too long");
bzero(&sa, sizeof(sa)); bzero(&sa, sizeof(sa));
sa.sun_family = AF_UNIX; sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, server_path); strcpy(sa.sun_path, server_path);
......
...@@ -865,6 +865,10 @@ sk_open_unix(sock *s, char *name) ...@@ -865,6 +865,10 @@ sk_open_unix(sock *s, char *name)
if (err = sk_setup(s)) if (err = sk_setup(s))
goto bad; goto bad;
unlink(name); unlink(name);
if (strlen(name) >= sizeof(sa.sun_path))
die("sk_open_unix: path too long");
sa.sun_family = AF_UNIX; sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, name); strcpy(sa.sun_path, name);
if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0) if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment