qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH 1/4] qemu-char: fix parameter check for qemu_chr_o


From: zhanghailiang
Subject: [Qemu-trivial] [PATCH 1/4] qemu-char: fix parameter check for qemu_chr_open_pipe
Date: Sat, 1 Nov 2014 09:50:00 +0800

The filename parameter never to be NULL, because in qemu_chr_parse_pipe
it is return value of g_strdup(device), where device will not be
NULL.

We should check its length.
After this patch, when run command:
 qemu-system-x86_64 -chardev pipe,id=pipe1,path=
It will report error:
 chardev: pipe: no filename given

Signed-off-by: zhanghailiang <address@hidden>
---
 qemu-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index bd0709b..42b1d8f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1084,7 +1084,7 @@ static CharDriverState *qemu_chr_open_pipe(ChardevHostdev 
*opts)
     char filename_out[CHR_MAX_FILENAME_SIZE];
     const char *filename = opts->device;
 
-    if (filename == NULL) {
+    if (filename == NULL || strlen(filename) == 0) {
         fprintf(stderr, "chardev: pipe: no filename given\n");
         return NULL;
     }
-- 
1.7.12.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]