[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH v2 1/5] qemu-char: fix parameter check for some qe
From: |
zhanghailiang |
Subject: |
[Qemu-trivial] [PATCH v2 1/5] qemu-char: fix parameter check for some qemu_chr_parse_* functions |
Date: |
Mon, 3 Nov 2014 17:44:28 +0800 |
For some qemu_chr_parse_* functions, we just check whether the parameter
is NULL or not, not check its length.
For example:
qemu-system-x86_64 -chardev pipe,id=id,path=
It will pass the check of NULL, and finds the error until trying
to open it.
So we should find the error by check its length, just like what
qemu_chr_parse_udp does, it will help find what exactly is wrong.
Signed-off-by: zhanghailiang <address@hidden>
---
qemu-char.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index bd0709b..04d747a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3419,7 +3419,7 @@ static void qemu_chr_parse_file_out(QemuOpts *opts,
ChardevBackend *backend,
{
const char *path = qemu_opt_get(opts, "path");
- if (path == NULL) {
+ if (path == NULL || strlen(path) == 0) {
error_setg(errp, "chardev: file: no filename given");
return;
}
@@ -3453,7 +3453,7 @@ static void qemu_chr_parse_parallel(QemuOpts *opts,
ChardevBackend *backend,
{
const char *device = qemu_opt_get(opts, "path");
- if (device == NULL) {
+ if (device == NULL || strlen(device) == 0) {
error_setg(errp, "chardev: parallel: no device path given");
return;
}
@@ -3466,7 +3466,7 @@ static void qemu_chr_parse_pipe(QemuOpts *opts,
ChardevBackend *backend,
{
const char *device = qemu_opt_get(opts, "path");
- if (device == NULL) {
+ if (device == NULL || strlen(device) == 0) {
error_setg(errp, "chardev: pipe: no device path given");
return;
}
@@ -3515,11 +3515,11 @@ static void qemu_chr_parse_socket(QemuOpts *opts,
ChardevBackend *backend,
SocketAddress *addr;
if (!path) {
- if (!host) {
+ if (!host || strlen(host) == 0) {
error_setg(errp, "chardev: socket: no host given");
return;
}
- if (!port) {
+ if (!port || strlen(port) == 0) {
error_setg(errp, "chardev: socket: no port given");
return;
}
--
1.7.12.4
- [Qemu-trivial] [PATCH v2 0/5] Trivial patch about qemu-char, zhanghailiang, 2014/11/03
- [Qemu-trivial] [PATCH v2 3/5] spice-qemu-char: fix parameter checks for qemu_chr_parse_* functions, zhanghailiang, 2014/11/03
- [Qemu-trivial] [PATCH v2 4/5] qemu-char: convert some open functions to use Error API, zhanghailiang, 2014/11/03
- [Qemu-trivial] [PATCH v2 2/5] qemu-char: remove unnecessary in-parameter check for qemu_chr_parse_pipe, zhanghailiang, 2014/11/03
- [Qemu-trivial] [PATCH v2 5/5] spice-qemu-char: convert qemu_chr_open_spice_vmc to use Error API, zhanghailiang, 2014/11/03
- [Qemu-trivial] [PATCH v2 1/5] qemu-char: fix parameter check for some qemu_chr_parse_* functions,
zhanghailiang <=
- Re: [Qemu-trivial] [PATCH v2 0/5] Trivial patch about qemu-char, Michael Tokarev, 2014/11/03