From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Michael Tokarev <mjt@tls.msk.ru>, <qemu-trivial@nongnu.org>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com
Subject: Re: [Qemu-trivial] [PATCH 1/4] qemu-char: fix parameter check for qemu_chr_open_pipe
Date: Mon, 3 Nov 2014 10:59:33 +0800 [thread overview]
Message-ID: <5456EF95.5050502@huawei.com> (raw)
In-Reply-To: <5455BE99.1000400@msgid.tls.msk.ru>
On 2014/11/2 13:18, Michael Tokarev wrote:
> 01.11.2014 04:50, zhanghailiang wrote:
>> 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 <zhang.zhanghailiang@huawei.com>
>> ---
>> 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;
>> }
>
> and chr_parse_pipe() looks like:
>
>
> static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
> Error **errp)
> {
> const char *device = qemu_opt_get(opts, "path");
>
> if (device == NULL) {
> error_setg(errp, "chardev: pipe: no device path given");
> return;
> }
>
> Maybe we should combine the two checks into one in chr_parse_pipe,
> and remove the check in chr_open_pipe entirely?
Good idea, This is just like what qemu_chr_parse_udp does ;) Thanks.
> .
>
WARNING: multiple messages have this Message-ID (diff)
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-trivial@nongnu.org
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/4] qemu-char: fix parameter check for qemu_chr_open_pipe
Date: Mon, 3 Nov 2014 10:59:33 +0800 [thread overview]
Message-ID: <5456EF95.5050502@huawei.com> (raw)
In-Reply-To: <5455BE99.1000400@msgid.tls.msk.ru>
On 2014/11/2 13:18, Michael Tokarev wrote:
> 01.11.2014 04:50, zhanghailiang wrote:
>> 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 <zhang.zhanghailiang@huawei.com>
>> ---
>> 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;
>> }
>
> and chr_parse_pipe() looks like:
>
>
> static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
> Error **errp)
> {
> const char *device = qemu_opt_get(opts, "path");
>
> if (device == NULL) {
> error_setg(errp, "chardev: pipe: no device path given");
> return;
> }
>
> Maybe we should combine the two checks into one in chr_parse_pipe,
> and remove the check in chr_open_pipe entirely?
Good idea, This is just like what qemu_chr_parse_udp does ;) Thanks.
> .
>
next prev parent reply other threads:[~2014-11-03 3:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-01 1:49 [Qemu-trivial] [PATCH 0/4] Trivial patches about qemu-char zhanghailiang
2014-11-01 1:49 ` [Qemu-devel] " zhanghailiang
2014-11-01 1:50 ` [Qemu-trivial] [PATCH 1/4] qemu-char: fix parameter check for qemu_chr_open_pipe zhanghailiang
2014-11-01 1:50 ` [Qemu-devel] " zhanghailiang
2014-11-02 5:18 ` [Qemu-trivial] " Michael Tokarev
2014-11-02 5:18 ` [Qemu-devel] " Michael Tokarev
2014-11-03 2:59 ` zhanghailiang [this message]
2014-11-03 2:59 ` zhanghailiang
2014-11-01 1:50 ` [Qemu-trivial] [PATCH 2/4] spice-qemu-char: fix check for in-parameter zhanghailiang
2014-11-01 1:50 ` [Qemu-devel] " zhanghailiang
2014-11-02 6:50 ` [Qemu-trivial] " Michael Tokarev
2014-11-02 6:50 ` [Qemu-devel] " Michael Tokarev
2014-11-03 3:00 ` zhanghailiang
2014-11-03 3:00 ` [Qemu-devel] " zhanghailiang
2014-11-01 1:50 ` [Qemu-trivial] [PATCH 3/4] qemu-char: convert some open functions to use Error API zhanghailiang
2014-11-01 1:50 ` [Qemu-devel] " zhanghailiang
2014-11-01 15:18 ` [Qemu-trivial] " Eric Blake
2014-11-01 15:18 ` Eric Blake
2014-11-03 2:46 ` [Qemu-trivial] " zhanghailiang
2014-11-03 2:46 ` zhanghailiang
2014-11-01 1:50 ` [Qemu-trivial] [PATCH 4/4] spice-qemu-char: convert " zhanghailiang
2014-11-01 1:50 ` [Qemu-devel] " zhanghailiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5456EF95.5050502@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.