All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vnc: fix segmentation fault when invalid vnc parameters are specified
@ 2015-03-12  3:59 arei.gonglei
  2015-03-12  7:07 ` Michael Tokarev
  0 siblings, 1 reply; 3+ messages in thread
From: arei.gonglei @ 2015-03-12  3:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, peter.huangpeng, kraxel

From: Gonglei <arei.gonglei@huawei.com>

Reproducer:
 #./qemu-system-x86_64 -vnc :0,ip
qemu-system-x86_64: -vnc :1,ip: Invalid parameter 'ip'
Segmentation fault (core dumped)

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 This patch bases on Gerd's vnc queue.
---
 ui/vnc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 4b6ef1e..59b3aff 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3698,8 +3698,13 @@ QemuOpts *vnc_parse_func(const char *str)
 {
     QemuOptsList *olist = qemu_find_opts("vnc");
     QemuOpts *opts = qemu_opts_parse(olist, str, 1);
-    const char *id = qemu_opts_id(opts);
+    const char *id = NULL;
 
+    if (!opts) {
+        return NULL;
+    }
+
+    id = qemu_opts_id(opts);
     if (!id) {
         /* auto-assign id if not present */
         vnc_auto_assign_id(olist, opts);
-- 
1.7.12.4

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

* Re: [Qemu-devel] [PATCH] vnc: fix segmentation fault when invalid vnc parameters are specified
  2015-03-12  3:59 [Qemu-devel] [PATCH] vnc: fix segmentation fault when invalid vnc parameters are specified arei.gonglei
@ 2015-03-12  7:07 ` Michael Tokarev
  2015-03-12  7:22   ` Gonglei
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Tokarev @ 2015-03-12  7:07 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel; +Cc: peter.huangpeng, kraxel

12.03.2015 06:59, arei.gonglei@huawei.com wrote:
> +++ b/ui/vnc.c
> @@ -3698,8 +3698,13 @@ QemuOpts *vnc_parse_func(const char *str)
>  {
>      QemuOptsList *olist = qemu_find_opts("vnc");
>      QemuOpts *opts = qemu_opts_parse(olist, str, 1);
> -    const char *id = qemu_opts_id(opts);
> +    const char *id = NULL;

Useless initializer.

/mjt

> +    if (!opts) {
> +        return NULL;
> +    }
> +
> +    id = qemu_opts_id(opts);

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

* Re: [Qemu-devel] [PATCH] vnc: fix segmentation fault when invalid vnc parameters are specified
  2015-03-12  7:07 ` Michael Tokarev
@ 2015-03-12  7:22   ` Gonglei
  0 siblings, 0 replies; 3+ messages in thread
From: Gonglei @ 2015-03-12  7:22 UTC (permalink / raw)
  To: Michael Tokarev, qemu-devel; +Cc: peter.huangpeng, kraxel

On 2015/3/12 15:07, Michael Tokarev wrote:
> 12.03.2015 06:59, arei.gonglei@huawei.com wrote:
>> +++ b/ui/vnc.c
>> @@ -3698,8 +3698,13 @@ QemuOpts *vnc_parse_func(const char *str)
>>  {
>>      QemuOptsList *olist = qemu_find_opts("vnc");
>>      QemuOpts *opts = qemu_opts_parse(olist, str, 1);
>> -    const char *id = qemu_opts_id(opts);
>> +    const char *id = NULL;
> 
> Useless initializer.
> 
Okay, will fix, thanks.

Regards,
-Gonglei
> /mjt
> 
>> +    if (!opts) {
>> +        return NULL;
>> +    }
>> +
>> +    id = qemu_opts_id(opts);
> 

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

end of thread, other threads:[~2015-03-12  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12  3:59 [Qemu-devel] [PATCH] vnc: fix segmentation fault when invalid vnc parameters are specified arei.gonglei
2015-03-12  7:07 ` Michael Tokarev
2015-03-12  7:22   ` Gonglei

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.