tests/virtio-9p: v9fs_string_read() didn't terminate string
PATCH 1/9 tests/virtio-9p: v9fs_string_read() didn't terminate string
Signed-off-by Christian Schoenebeck <[email protected]>
--- tests/virtio-9p-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/virtio-9p-test.c +2 -1
@@ -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); }
Signature · 1 line
2.20.1
An affirmative form would provide a better one-line summary of what this patch does, eg:
Add terminating nul in v9fs_string_read().
And maybe explain that, despite it is well known that strings don't have a terminating nul in 9P, this will allow future users of v9fs_string_read() to use regular C library string functions with the returned string.
Quoted 10 lines · On Mon, 16 Dec 2019 00:17:48 +0100 Christian Schoenebeck…
Signed-off-by Christian Schoenebeck <[email protected]>--- tests/virtio-9p-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tests/virtio-9p-test.c +0
-0
tests/virtio-9p-test.c static void v9fs_string_read(P9Req *req, uint16_t *len, char **string) · line 133
Quoted 5 lines
tests/virtio-9p-test.c +1
-1@@ -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 );
ERROR: spaces required around that '+' (ctx:VxV)
#97: FILE: tests/virtio-9p-test.c:133:
+ *string = g_malloc(local_len+1);
Quoted 5 lines
tests/virtio-9p-test.c +1
-0v9fs_memread (req, *string, local_len); + (*string)[local_len] =0 ; }else {v9fs_memskip (req, local_len); }