macro: add LXC_AUDS_ADDR_LEN

parent 253a7210
...@@ -1239,7 +1239,7 @@ out_close: ...@@ -1239,7 +1239,7 @@ out_close:
int lxc_cmd_init(const char *name, const char *lxcpath, const char *suffix) int lxc_cmd_init(const char *name, const char *lxcpath, const char *suffix)
{ {
int fd, len, ret; int fd, len, ret;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = {0}; char path[LXC_AUDS_ADDR_LEN] = {0};
char *offset = &path[1]; char *offset = &path[1];
/* -2 here because this is an abstract unix socket so it needs a /* -2 here because this is an abstract unix socket so it needs a
......
...@@ -162,7 +162,7 @@ int lxc_cmd_connect(const char *name, const char *lxcpath, ...@@ -162,7 +162,7 @@ int lxc_cmd_connect(const char *name, const char *lxcpath,
const char *hashed_sock_name, const char *suffix) const char *hashed_sock_name, const char *suffix)
{ {
int ret, client_fd; int ret, client_fd;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = {0}; char path[LXC_AUDS_ADDR_LEN] = {0};
char *offset = &path[1]; char *offset = &path[1];
/* -2 here because this is an abstract unix socket so it needs a /* -2 here because this is an abstract unix socket so it needs a
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h>
/* Define __S_ISTYPE if missing from the C library. */ /* Define __S_ISTYPE if missing from the C library. */
#ifndef __S_ISTYPE #ifndef __S_ISTYPE
...@@ -238,6 +239,9 @@ extern int __build_bug_on_failed; ...@@ -238,6 +239,9 @@ extern int __build_bug_on_failed;
#define MACVLAN_MODE_PASSTHRU 8 #define MACVLAN_MODE_PASSTHRU 8
#endif #endif
/* Length of abstract unix domain socket socket address. */
#define LXC_AUDS_ADDR_LEN sizeof(((struct sockaddr_un *)0)->sun_path)
/* mount */ /* mount */
#ifndef MS_REC #ifndef MS_REC
#define MS_REC 16384 #define MS_REC 16384
......
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