From feff2efa9a45f1f0db9ec4247ce32bed2d6631d1 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 29 Mar 2017 23:15:00 +0300 Subject: [PATCH] zdtm/dumpable02: don't print a non-null terminated string Signed-off-by: Andrei Vagin --- test/zdtm/static/dumpable02.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/zdtm/static/dumpable02.c b/test/zdtm/static/dumpable02.c index 3463deda7..bd632e13e 100644 --- a/test/zdtm/static/dumpable02.c +++ b/test/zdtm/static/dumpable02.c @@ -36,11 +36,12 @@ int get_dumpable_from_pipes(int pipe_input, int pipe_output) { /* input and output are from the child's point of view. */ write(pipe_input, "GET\n", 4); - len = read(pipe_output, buf, sizeof(buf)); + len = read(pipe_output, buf, sizeof(buf) - 1); if (len < 0) { pr_perror("error in parent reading from pipe"); return -1; } + buf[len] = 0; if (memcmp(buf, "DUMPABLE:", 9) != 0) { pr_perror("child returned [%s]", buf);