qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends
@ 2011-11-08 12:45 Markus Armbruster
  2011-11-08 13:14 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 12:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
fails.  Spotted by Coverity.
---
 ui/vnc-auth-sasl.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 23b1bf5..e2045fc 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -35,7 +35,7 @@ void vnc_sasl_client_cleanup(VncState *vs)
         vs->sasl.encodedLength = vs->sasl.encodedOffset = 0;
         vs->sasl.encoded = NULL;
         g_free(vs->sasl.username);
-        free(vs->sasl.mechlist);
+        g_free(vs->sasl.mechlist);
         vs->sasl.username = vs->sasl.mechlist = NULL;
         sasl_dispose(&vs->sasl.conn);
         vs->sasl.conn = NULL;
@@ -430,11 +430,7 @@ static int protocol_client_auth_sasl_start_len(VncState *vs, uint8_t *data, size
 
 static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_t len)
 {
-    char *mechname = malloc(len + 1);
-    if (!mechname) {
-        VNC_DEBUG("Out of memory reading mechname\n");
-        vnc_client_error(vs);
-    }
+    char *mechname = g_malloc(len + 1);
     strncpy(mechname, (char*)data, len);
     mechname[len] = '\0';
     VNC_DEBUG("Got client mechname '%s' check against '%s'\n",
@@ -460,7 +456,7 @@ static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_
         }
     }
 
-    free(vs->sasl.mechlist);
+    g_free(vs->sasl.mechlist);
     vs->sasl.mechlist = mechname;
 
     VNC_DEBUG("Validated mechname '%s'\n", mechname);
@@ -469,7 +465,7 @@ static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_
 
  fail:
     vnc_client_error(vs);
-    free(mechname);
+    g_free(mechname);
     return -1;
 }
 
@@ -608,12 +604,7 @@ void start_auth_sasl(VncState *vs)
     }
     VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist);
 
-    if (!(vs->sasl.mechlist = strdup(mechlist))) {
-        VNC_DEBUG("Out of memory");
-        sasl_dispose(&vs->sasl.conn);
-        vs->sasl.conn = NULL;
-        goto authabort;
-    }
+    vs->sasl.mechlist = g_strdup(mechlist);
     mechlistlen = strlen(mechlist);
     vnc_write_u32(vs, mechlistlen);
     vnc_write(vs, mechlist, mechlistlen);
-- 
1.7.6.4

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends
  2011-11-08 12:45 [Qemu-devel] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends Markus Armbruster
@ 2011-11-08 13:14 ` Stefan Hajnoczi
  2011-11-08 14:25   ` Markus Armbruster
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2011-11-08 13:14 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-trivial, qemu-devel

On Tue, Nov 8, 2011 at 12:45 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
> fails.  Spotted by Coverity.
> ---
>  ui/vnc-auth-sasl.c |   19 +++++--------------
>  1 files changed, 5 insertions(+), 14 deletions(-)

Looks good, please add Signed-off-by.

Stefan

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends
  2011-11-08 13:14 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
@ 2011-11-08 14:25   ` Markus Armbruster
  2011-11-08 14:34     ` 陳韋任
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 14:25 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-trivial, qemu-devel

Stefan Hajnoczi <stefanha@gmail.com> writes:

> On Tue, Nov 8, 2011 at 12:45 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
>> fails.  Spotted by Coverity.
>> ---
>>  ui/vnc-auth-sasl.c |   19 +++++--------------
>>  1 files changed, 5 insertions(+), 14 deletions(-)
>
> Looks good, please add Signed-off-by.

Gaa, too trivial to get it right in less than three tries!  There must a
curse of brainlessness on this one...

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends
  2011-11-08 14:25   ` Markus Armbruster
@ 2011-11-08 14:34     ` 陳韋任
  2011-11-08 14:44       ` Kevin Wolf
  0 siblings, 1 reply; 5+ messages in thread
From: 陳韋任 @ 2011-11-08 14:34 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-trivial, Stefan Hajnoczi, qemu-devel

> Stefan Hajnoczi <stefanha@gmail.com> writes:
> 
> > On Tue, Nov 8, 2011 at 12:45 PM, Markus Armbruster <armbru@redhat.com> wrote:
> >> Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
> >> fails.  Spotted by Coverity.
> >> ---
> >>  ui/vnc-auth-sasl.c |   19 +++++--------------
> >>  1 files changed, 5 insertions(+), 14 deletions(-)
> >
> > Looks good, please add Signed-off-by.
> 
> Gaa, too trivial to get it right in less than three tries!  There must a
> curse of brainlessness on this one...

  `git-format-patch -s` will generate the sign-off-by.

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends
  2011-11-08 14:34     ` 陳韋任
@ 2011-11-08 14:44       ` Kevin Wolf
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2011-11-08 14:44 UTC (permalink / raw)
  To: 陳韋任
  Cc: qemu-trivial, Stefan Hajnoczi, Markus Armbruster, qemu-devel

Am 08.11.2011 15:34, schrieb 陳韋任:
>> Stefan Hajnoczi <stefanha@gmail.com> writes:
>>
>>> On Tue, Nov 8, 2011 at 12:45 PM, Markus Armbruster <armbru@redhat.com> wrote:
>>>> Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
>>>> fails.  Spotted by Coverity.
>>>> ---
>>>>  ui/vnc-auth-sasl.c |   19 +++++--------------
>>>>  1 files changed, 5 insertions(+), 14 deletions(-)
>>>
>>> Looks good, please add Signed-off-by.
>>
>> Gaa, too trivial to get it right in less than three tries!  There must a
>> curse of brainlessness on this one...
> 
>   `git-format-patch -s` will generate the sign-off-by.

And git commit -s will make sure that it doesn't disappear in v2 when it
was there in v1.

Kevin

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

end of thread, other threads:[~2011-11-08 14:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 12:45 [Qemu-devel] [PATCH v2] ui/vnc: Convert sasl.mechlist to g_malloc() & friends Markus Armbruster
2011-11-08 13:14 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2011-11-08 14:25   ` Markus Armbruster
2011-11-08 14:34     ` 陳韋任
2011-11-08 14:44       ` Kevin Wolf

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).