[CRIU] [PATCH 2/2] zdtm/unix: add zero characters into a socket address
Andrei Vagin
avagin at openvz.org
Thu Mar 30 12:00:57 PDT 2017
From: Andrei Vagin <avagin at virtuozzo.com>
An abstract name can contain zero characters.
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
test/zdtm/static/sk-unix-unconn.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/zdtm/static/sk-unix-unconn.c b/test/zdtm/static/sk-unix-unconn.c
index 8e60013..abf59e3 100644
--- a/test/zdtm/static/sk-unix-unconn.c
+++ b/test/zdtm/static/sk-unix-unconn.c
@@ -12,7 +12,7 @@ const char *test_author = "Vagin Andrew <avagin at parallels.com>";
int main(int argc, char ** argv)
{
int sk, skc;
- int ret;
+ int ret, len;
char path[PATH_MAX];
struct sockaddr_un addr;
socklen_t addrlen;
@@ -31,12 +31,13 @@ int main(int argc, char ** argv)
return 1;
}
- snprintf(path, sizeof(path), "X/zdtm-%s-%d", argv[0], getpid());
+ len = snprintf(path, sizeof(path), "X/zdtm-%s-%d/X", argv[0], getpid());
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
- addrlen = sizeof(addr.sun_family) + strlen(path);
+ addrlen = sizeof(addr.sun_family) + len;
addr.sun_path[0] = 0;
+ addr.sun_path[len - 1] = 0;
ret = bind(sk, (struct sockaddr *) &addr, addrlen);
if (ret) {
--
2.7.4
More information about the CRIU
mailing list