[CRIU] [PATCH] criu/test/zdtm/sockets_dgram: check the length of path used

Yicheng Qin yichengq at google.com
Tue Aug 6 17:30:11 EDT 2013


From: Yicheng Qin <yichengq at google.com>
Subject: [PATCH] test/zdtm/sockets_dgram: check the length of path used

Path generated in the test is copied into sun_path attribute in
struct sockaddr_un. Additional check on whether sun_path can
contain the whole path is added. It is useful because if sun_path
can only contain the first part of the path, all sockadd_un
will point to the same location, which leads to error.

Signed-off-by: Yicheng Qin <yichengq at google.com>
---
 test/zdtm/live/static/sockets_dgram.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/test/zdtm/live/static/sockets_dgram.c
b/test/zdtm/live/static/sockets_dgram.c
index b914111..1df0570 100644
--- a/test/zdtm/live/static/sockets_dgram.c
+++ b/test/zdtm/live/static/sockets_dgram.c
@@ -73,18 +73,30 @@ int main(int argc, char *argv[])

        snprintf(path, sizeof(path), "%s/%s.bound", cwd, filename);
        unlink(path);
+       if (strlen(path) >= sizeof(name_bound.sun_path)) {
+               fail("too long path");
+               exit(1);
+       }

        name_bound.sun_family = AF_UNIX;
        strncpy(name_bound.sun_path, path, sizeof(name_bound.sun_path));

        snprintf(path, sizeof(path), "%s/%s.conn", cwd, filename);
        unlink(path);
+       if (strlen(path) >= sizeof(name_conn.sun_path)) {
+               fail("too long path");
+               exit(1);
+       }

        name_conn.sun_family = AF_UNIX;
        strncpy(name_conn.sun_path, path, sizeof(name_conn.sun_path));

        snprintf(path, sizeof(path), "%s/%s.bound-conn", cwd, filename);
        unlink(path);
+       if (strlen(path) >= sizeof(name_bound_conn.sun_path)) {
+               fail("too long path");
+               exit(1);
+       }

        name_bound_conn.sun_family = AF_UNIX;
        strncpy(name_bound_conn.sun_path, path,
sizeof(name_bound_conn.sun_path));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20130806/a070d521/attachment.html>


More information about the CRIU mailing list