[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/6] tests/virtio-9p: add terminating null in v9fs_string_read()
From: |
Greg Kurz |
Subject: |
[PULL 1/6] tests/virtio-9p: add terminating null in v9fs_string_read() |
Date: |
Sat, 8 Feb 2020 11:45:01 +0100 |
From: Christian Schoenebeck <address@hidden>
The 9p protocol sends strings in general without null termination
over the wire. However for future use of this functions it is
beneficial for the delivered string to be null terminated though
for being able to use the string with standard C functions which
often rely on strings being null terminated.
Signed-off-by: Christian Schoenebeck <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
---
tests/qtest/virtio-9p-test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index e7b58e3a0c3c..06263edb53f9 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -130,8 +130,9 @@ static void v9fs_string_read(P9Req *req, uint16_t *len,
char **string)
*len = local_len;
}
if (string) {
- *string = g_malloc(local_len);
+ *string = g_malloc(local_len + 1);
v9fs_memread(req, *string, local_len);
+ (*string)[local_len] = 0;
} else {
v9fs_memskip(req, local_len);
}
--
2.21.1
- [PULL 0/6] 9p patches 2020-02-08, Greg Kurz, 2020/02/08
- [PULL 2/6] 9pfs: require msize >= 4096, Greg Kurz, 2020/02/08
- [PULL 1/6] tests/virtio-9p: add terminating null in v9fs_string_read(),
Greg Kurz <=
- [PULL 4/6] hw/9pfs/9p-synth: added directory for readdir test, Greg Kurz, 2020/02/08
- [PULL 6/6] MAINTAINERS: 9pfs: Add myself as reviewer, Greg Kurz, 2020/02/08
- [PULL 5/6] tests/virtio-9p: added readdir test, Greg Kurz, 2020/02/08
- [PULL 3/6] 9pfs: validate count sent by client with T_readdir, Greg Kurz, 2020/02/08
- Re: [PULL 0/6] 9p patches 2020-02-08, Peter Maydell, 2020/02/10