[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_re
From: |
Christian Schoenebeck |
Subject: |
[PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_read() |
Date: |
Mon, 13 Jan 2020 23:20:37 +0100 |
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>
---
tests/virtio-9p-test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index e7b58e3a0c..06263edb53 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/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.20.1
- [PATCH v3 07/11] tests/virtio-9p: failing splitted readdir test, (continued)
- [PATCH v3 05/11] tests/virtio-9p: added readdir test, Christian Schoenebeck, 2020/01/13
- [PATCH v3 08/11] 9pfs: readdir benchmark, Christian Schoenebeck, 2020/01/13
- [PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_read(),
Christian Schoenebeck <=
- [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/13
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/17
[PATCH v3 10/11] 9pfs: T_readdir latency optimization, Christian Schoenebeck, 2020/01/13