qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/9] tests/virtio-9p: v9fs_string_read() didn't terminate string
@ 2019-12-15 23:17 Christian Schoenebeck
  2019-12-18  8:47 ` Greg Kurz
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Schoenebeck @ 2019-12-15 23:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
 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..880b4ff567 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/9] tests/virtio-9p: v9fs_string_read() didn't terminate string
  2019-12-15 23:17 [PATCH 1/9] tests/virtio-9p: v9fs_string_read() didn't terminate string Christian Schoenebeck
@ 2019-12-18  8:47 ` Greg Kurz
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kurz @ 2019-12-18  8:47 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: qemu-devel

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.

On Mon, 16 Dec 2019 00:17:48 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>  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..880b4ff567 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);

ERROR: spaces required around that '+' (ctx:VxV)
#97: FILE: tests/virtio-9p-test.c:133:
+        *string = g_malloc(local_len+1);

>          v9fs_memread(req, *string, local_len);
> +        (*string)[local_len] = 0;
>      } else {
>          v9fs_memskip(req, local_len);
>      }



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-18  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-15 23:17 [PATCH 1/9] tests/virtio-9p: v9fs_string_read() didn't terminate string Christian Schoenebeck
2019-12-18  8:47 ` Greg Kurz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).