]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ui/vnc: simplify and avoid strncpy
authorJim Meyering <meyering@redhat.com>
Thu, 4 Oct 2012 11:09:54 +0000 (13:09 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 5 Oct 2012 12:58:37 +0000 (07:58 -0500)
Don't bother with strncpy.  There's no need for its zero-fill.
Use g_strndup in place of g_malloc+strncpy+NUL-terminate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
ui/vnc-auth-sasl.c

index 8fba7702c2a725567c6defab2abe11173030ecf4..bfdcb46efe7bb49fe38efe1fde537f63e051375a 100644 (file)
@@ -432,9 +432,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 = g_malloc(len + 1);
-    strncpy(mechname, (char*)data, len);
-    mechname[len] = '\0';
+    char *mechname = g_strndup((const char *) data, len);
     VNC_DEBUG("Got client mechname '%s' check against '%s'\n",
               mechname, vs->sasl.mechlist);