From: Ondrej Zajicek Date: Sun, 26 Oct 2008 22:55:38 +0000 (+0100) Subject: Check of socket name length X-Git-Tag: v1.2.0~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68fa95cfec78f1bfe790949bf747d578ad583ec2;p=thirdparty%2Fbird.git Check of socket name length --- diff --git a/client/client.c b/client/client.c index d65ea066b..e3f539e11 100644 --- a/client/client.c +++ b/client/client.c @@ -252,6 +252,10 @@ server_connect(void) server_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (server_fd < 0) die("Cannot create socket: %m"); + + if (strlen(server_path) >= sizeof(sa.sun_path)) + die("server_connect: path too long"); + bzero(&sa, sizeof(sa)); sa.sun_family = AF_UNIX; strcpy(sa.sun_path, server_path); diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 7dcca21ab..fa471f6e7 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -865,6 +865,10 @@ sk_open_unix(sock *s, char *name) if (err = sk_setup(s)) goto bad; unlink(name); + + if (strlen(name) >= sizeof(sa.sun_path)) + die("sk_open_unix: path too long"); + sa.sun_family = AF_UNIX; strcpy(sa.sun_path, name); if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0)