Ver código fonte

unix-socket: Check minimal length of socket path

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 4 anos atrás
pai
commit
c879b39086
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      qdevices/unix-socket.c

+ 2 - 2
qdevices/unix-socket.c

@@ -48,7 +48,7 @@ unix_socket_server_create(const char *path, int non_blocking, int backlog)
 	int s;
 	int s;
 	struct sockaddr_un sun;
 	struct sockaddr_un sun;
 
 
-	if (strlen(path) >= sizeof(sun.sun_path)) {
+	if (strlen(path) >= sizeof(sun.sun_path) || strlen(path) == 0) {
 		errno = ENAMETOOLONG;
 		errno = ENAMETOOLONG;
 		return (-1);
 		return (-1);
 	}
 	}
@@ -91,7 +91,7 @@ unix_socket_client_create(const char *path, int non_blocking)
 	int s;
 	int s;
 	struct sockaddr_un sun;
 	struct sockaddr_un sun;
 
 
-	if (strlen(path) >= sizeof(sun.sun_path)) {
+	if (strlen(path) >= sizeof(sun.sun_path) || strlen(path) == 0) {
 		errno = ENAMETOOLONG;
 		errno = ENAMETOOLONG;
 		return (-1);
 		return (-1);
 	}
 	}